Submission #87110
Source Code Expand
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
#define maxx(a,b) ((a>b) ? (a) : (b))
int tar[2005],ciz[2005];
int t,n,m,q;
void oku(){
int i;
scanf("%d %d %d",&q,&n,&m);
for(i=1;i<=n;i++){
scanf("%d",&tar[i]);
t+=tar[i];
}
for(i=1;i<=m;i++)
scanf("%d",&ciz[i]);
sort(ciz+1,ciz+1+m);
}
void coz(){
int r=0;
r=q;
if(t<q){
int i=m;
while(t<q){
t+=ciz[i--];
r--;
}
}
else{
bool knap[150005]={1};
int i,j,k=1;
for(i=1;i<=n && !knap[q];i++)
for(j=k;j>=0 && !knap[q];j--)
if(knap[j]){
knap[j+tar[i]]=1;
k=maxx(k,j+tar[i]);
}
if(!knap[q])
r--;
}
printf("%d\n",r);
}
int main(){
oku();
coz();
return 0;
}
Submission Info
Submission Time
2013-07-06 15:53:38+0900
Task
14 - Farmer
User
halilozanakgul
Language
C++ (GCC 4.4.7)
Score
100
Code Size
756 Byte
Status
AC
Exec Time
311 ms
Memory
940 KB
Compile Error
./Main.cpp: In function ‘void oku()’:
./Main.cpp:11: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result
./Main.cpp:13: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result
./Main.cpp:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result
Judge Result
Set Name
Set01
Set02
Set03
Set04
Set05
Set06
Set07
Set08
Set09
Set10
Set11
Set12
Set13
Set14
Set15
Set16
Set17
Set18
Set19
Set20
Score / Max Score
5 / 5
5 / 5
5 / 5
5 / 5
5 / 5
5 / 5
5 / 5
5 / 5
5 / 5
5 / 5
5 / 5
5 / 5
5 / 5
5 / 5
5 / 5
5 / 5
5 / 5
5 / 5
5 / 5
5 / 5
Status
Set Name
Test Cases
Set01
01
Set02
02
Set03
03
Set04
04
Set05
05
Set06
06
Set07
07
Set08
08
Set09
09
Set10
10
Set11
11
Set12
12
Set13
13
Set14
14
Set15
15
Set16
16
Set17
17
Set18
18
Set19
19
Set20
20
Case Name
Status
Exec Time
Memory
01
AC
21 ms
912 KB
02
AC
21 ms
836 KB
03
AC
20 ms
896 KB
04
AC
20 ms
788 KB
05
AC
19 ms
788 KB
06
AC
21 ms
908 KB
07
AC
21 ms
912 KB
08
AC
21 ms
940 KB
09
AC
21 ms
900 KB
10
AC
20 ms
780 KB
11
AC
105 ms
832 KB
12
AC
20 ms
768 KB
13
AC
20 ms
700 KB
14
AC
20 ms
784 KB
15
AC
21 ms
784 KB
16
AC
20 ms
780 KB
17
AC
21 ms
788 KB
18
AC
20 ms
780 KB
19
AC
20 ms
784 KB
20
AC
311 ms
904 KB