Submission #330181
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 ans,H[2005],x;
vector<int> V;
int f(){
ans = 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;
ans += min(V[i],n)-1;
n -= min(V[i],n);
}
return ans;
}
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;
printf("%d",f());
return 0;
}
Submission Info
Submission Time
2015-02-02 17:54:50+0900
Task
14 - Farmer
User
Kerem
Language
C++ (G++ 4.6.4)
Score
0
Code Size
1032 Byte
Status
WA
Exec Time
508 ms
Memory
1468 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:46:30: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
./Main.cpp:49:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
./Main.cpp:52: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
29 ms
936 KB
02
WA
27 ms
1044 KB
03
WA
27 ms
924 KB
04
WA
27 ms
956 KB
05
WA
27 ms
952 KB
06
WA
27 ms
952 KB
07
WA
27 ms
948 KB
08
WA
28 ms
872 KB
09
WA
26 ms
984 KB
10
WA
30 ms
1052 KB
11
WA
162 ms
1208 KB
12
WA
188 ms
1216 KB
13
WA
209 ms
1136 KB
14
WA
215 ms
1212 KB
15
WA
240 ms
1204 KB
16
WA
304 ms
1336 KB
17
WA
338 ms
1336 KB
18
WA
405 ms
1336 KB
19
WA
508 ms
1332 KB
20
WA
474 ms
1468 KB