Submission #330149
Source Code Expand
#include<bits/stdc++.h>
using namespace std;
int q,m,k,i,j;
int T[2005],S[2005];
int DP[1000005],Q[1000005];
int main(){
memset(Q,10,sizeof Q);
scanf("%d %d %d",&q,&m,&k);
for(i=1 ; i<=m ; i++)
scanf("%d",T+i);
for(i=1 ; i<=k ; i++)
scanf("%d",S+i);
DP[0]=1;
for(i=1 ; i<=m ; i++)
for(j=150000 ; j>=0 ; j--)
if(DP[j]){
if(Q[j]==168430090 and T[i]>q){
DP[q-1]=1;
Q[q-1]=q;
continue;
}
if(Q[j]+T[i]>q){
DP[q-1]=1;
Q[q-1]=min(Q[q-1],q);
}
DP[T[i]+j]=1;
if(Q[j]==168430090)
Q[T[i]+j]=T[i];
else
Q[T[i]+j]=min(Q[T[i]+j],Q[j]+T[i]);
}
for(i=1 ; i<=k ; i++)
for(j=150000 ; j>=0 ; j--)
if(DP[j] and (Q[j]==168430090 or Q[j]+S[i]<=q) ){
DP[S[i]+j-1]=1;
if(Q[j]==168430090)
Q[S[i]+j-1]=S[i];
else
Q[S[i]+j-1]=min(Q[S[i]+j],Q[j]+S[i]);
}
for(i=q ; i>=0 ; i--)
if(DP[i])
return cout<<i,0;
return 0;
}
Submission Info
Submission Time
2015-02-02 17:17:26+0900
Task
14 - Farmer
User
berasogut
Language
C++ (G++ 4.6.4)
Score
0
Code Size
1225 Byte
Status
WA
Exec Time
1036 ms
Memory
5408 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:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
./Main.cpp:21:22: 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
38 ms
4648 KB
02
WA
48 ms
4644 KB
03
WA
35 ms
4648 KB
04
WA
35 ms
4648 KB
05
WA
34 ms
4648 KB
06
WA
51 ms
4640 KB
07
WA
52 ms
4648 KB
08
WA
51 ms
4640 KB
09
WA
52 ms
4628 KB
10
WA
52 ms
4652 KB
11
TLE
1033 ms
5292 KB
12
TLE
1033 ms
5280 KB
13
TLE
1034 ms
5376 KB
14
TLE
1034 ms
5408 KB
15
TLE
1033 ms
5408 KB
16
TLE
1034 ms
5284 KB
17
TLE
1033 ms
5280 KB
18
TLE
1034 ms
5220 KB
19
TLE
1036 ms
5152 KB
20
WA
954 ms
5280 KB