Submission #330189
Source Code Expand
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
int n,m,k,i,j;
int A[2004],B[2004],dp[150004];
int cvp,H[2005],x;
vector<int> V;
int main(){
scanf("%d %d %d",&n,&m,&k);
for(i=1 ; i<=m ; i++)
scanf("%d",&A[i]);
for(i=1 ; i<=k ; i++)
scanf("%d",&B[i]);
sort(A+1,A+m+1);
dp[0] = -1;
for(i=1 ; i<=m ; i++)
for(j=n ; j>=0 ; j--)
if(!dp[A[i]+j] && dp[j])
dp[A[i]+j] = i;
for(i=n ; i>=0 ; i--)
if(dp[i])
break;
cvp = x = i;
n -= x;
while(dp[x] != -1)
{
H[dp[x]] = 1;
x -= A[dp[x]];
}
for(i=1 ; i<=m ; i++)
if(!H[i])
V.pb(A[i]);
for(i=1 ; i<=k ; i++)
V.pb(B[i]);
sort(V.begin(),V.end());
for(i=V.size()-1 ; i>=0 ; i--)
{
if(!n)
break;
cvp += min(V[i],n)-1;
n -= min(V[i],n);
}
printf("%d",cvp);
return 0;
}
Submission Info
Submission Time
2015-02-02 18:02:52+0900
Task
14 - Farmer
User
Kerem
Language
C++ (G++ 4.6.4)
Score
0
Code Size
1030 Byte
Status
WA
Exec Time
575 ms
Memory
1320 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:15:30: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
./Main.cpp:18:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
./Main.cpp:21:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-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
0 / 5
0 / 5
0 / 5
0 / 5
0 / 5
0 / 5
0 / 5
0 / 5
0 / 5
0 / 5
0 / 5
0 / 5
0 / 5
0 / 5
0 / 5
0 / 5
0 / 5
0 / 5
0 / 5
0 / 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
WA
25 ms
928 KB
02
WA
26 ms
800 KB
03
WA
26 ms
804 KB
04
WA
23 ms
816 KB
05
WA
25 ms
808 KB
06
WA
24 ms
800 KB
07
WA
25 ms
740 KB
08
WA
26 ms
800 KB
09
WA
25 ms
764 KB
10
WA
25 ms
804 KB
11
WA
179 ms
1064 KB
12
WA
209 ms
1060 KB
13
WA
223 ms
1056 KB
14
WA
237 ms
1064 KB
15
WA
265 ms
1060 KB
16
WA
338 ms
1060 KB
17
WA
376 ms
1060 KB
18
WA
451 ms
1056 KB
19
WA
575 ms
1064 KB
20
WA
565 ms
1320 KB