Submission #330193
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
int q,m,k,t,T[2005],S[2005],res;
bool dp[150005];
void solve()
{
int i,s=0,d;
for(i=q;i>=0;i--)
if(dp[i])
break;
if(i==q)
{
res=q;
return;
}
if(i<t)
{
res=q-1;
return;
}
d=q-i;
for(i=1;i<=k;i++)
{
if(d>0)
{
s++;
d-=S[i];
}
else
break;
}
res=q-s;
}
int main()
{
int i,j;
scanf("%d %d %d",&q,&m,&k);
for(i=1;i<=m;i++)
{
scanf("%d",&T[i]);
t+=T[i];
}
for(i=1;i<=k;i++)
scanf("%d",&S[i]);
sort(S+1,S+k+1,greater < int > ());
dp[0]=1;
for(i=1;i<=m;i++)
for(j=q-T[i];j>=0;j--)
if(dp[j])
dp[j+T[i]]=1;
solve();
printf("%d\n",res);
return 0;
}
Submission Info
Submission Time
2015-02-02 18:09:08+0900
Task
14 - Farmer
User
Kerem
Language
C++ (G++ 4.6.4)
Score
100
Code Size
876 Byte
Status
AC
Exec Time
474 ms
Memory
932 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:50:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
./Main.cpp:55:24: 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
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
27 ms
780 KB
02
AC
25 ms
804 KB
03
AC
23 ms
800 KB
04
AC
25 ms
684 KB
05
AC
25 ms
932 KB
06
AC
26 ms
928 KB
07
AC
26 ms
924 KB
08
AC
24 ms
804 KB
09
AC
26 ms
928 KB
10
AC
23 ms
748 KB
11
AC
163 ms
864 KB
12
AC
185 ms
800 KB
13
AC
191 ms
928 KB
14
AC
210 ms
800 KB
15
AC
225 ms
800 KB
16
AC
299 ms
928 KB
17
AC
326 ms
800 KB
18
AC
382 ms
808 KB
19
AC
467 ms
856 KB
20
AC
474 ms
920 KB