Submission #88608
Source Code Expand
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#include <cmath>
#include <stack>
#define f first
#define s second
#define mkp make_pair
#define pb push_back
#define FILL(a,b) memset(a,b,sizeof(a))
#define FOR(a,b,c) for(a=b;a<=c;a++)
#define VFOR(a,b) for(a=0;a<b.size();a++)
#define ll long long
#define INF (int)1000000000
#define LINF (ll)1e16
#define vi vector<int>
using namespace std;
int N,M,K;
bool KN[300005];
int A1[2005];
int A2[5005];
int main()
{
int ans=0,i,j,mx=0,a=0,b=0;
scanf(" %d %d %d",&N,&M,&K);
FOR(i,1,M)
{
scanf(" %d",&A1[i]);
a+=A1[i];
}
FOR(i,1,K)
{
scanf(" %d",&A2[i]);
b+=A2[i];
}
if( a <= N )
{
ans=a;
N-=a;
sort(A2+1,A2+K+1,greater<int>());
FOR(i,1,K)
{
if(!N) break;
if(A2[i] <= N){ ans+=A2[i]-1; N-=A2[i]; continue; }
ans+=N-1;
N=0;
}
cout << ans << endl;
}
else
{
int mx=0;
KN[0]=1;
FOR(i,1,M)
{
for(j=mx;j>=0 && !KN[N]; j--)
if(KN[j])
{
KN[j+A1[i]]=1;
if(j+A1[i] > mx) mx=j+A1[i];
}
if(KN[N]) break;
}
if(!KN[N]) N--;
cout << N << endl;
}
return 0;
}
Submission Info
Submission Time
2013-07-06 21:13:33+0900
Task
14 - Farmer
User
oyildiz
Language
C++ (GCC 4.4.7)
Score
100
Code Size
1210 Byte
Status
AC
Exec Time
371 ms
Memory
812 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:31: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result
./Main.cpp:34: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result
./Main.cpp:39: 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
20 ms
668 KB
02
AC
19 ms
788 KB
03
AC
20 ms
788 KB
04
AC
19 ms
792 KB
05
AC
18 ms
812 KB
06
AC
20 ms
788 KB
07
AC
20 ms
796 KB
08
AC
19 ms
788 KB
09
AC
21 ms
788 KB
10
AC
19 ms
784 KB
11
AC
124 ms
796 KB
12
AC
20 ms
788 KB
13
AC
20 ms
800 KB
14
AC
20 ms
700 KB
15
AC
19 ms
788 KB
16
AC
20 ms
780 KB
17
AC
22 ms
772 KB
18
AC
19 ms
788 KB
19
AC
20 ms
792 KB
20
AC
371 ms
800 KB