Submission #181600


Source Code Expand

#include <stdio.h>
#include <algorithm>
#include <vector>
#include <bitset>

using namespace std;

int main()
{
	bitset<150005>b;
	int q,m,k;
	scanf("%d%d%d",&q,&m,&k);
	int x[2005],y[2005];
	for(int i=0;i<m;i++) scanf("%d",&x[i]);
	for(int i=0;i<k;i++) scanf("%d",&y[i]);
	b.set(0);
	for(int i=0;i<m;i++) b |= (b<<x[i]);
	if(b[q])
	{
		printf("%d\n",q);
		return 0;
	}
	int sum = 0;
	for(int i=0;i<m;i++) sum += x[i];
	if(sum >= q)
	{
		printf("%d\n",q-1);
		return 0;
	}
	sort(y,y+k);
	int gen = 0;
	for(int i=k-1;i>=0;i--)
	{
		sum += y[i];
		gen++;
		if(sum >= q)
		{
			printf("%d\n",q-gen);
			return 0;
		}
	}
}

Submission Info

Submission Time
Task 14 - Farmer
User IH19980412
Language C++ (G++ 4.6.4)
Score 100
Code Size 659 Byte
Status AC
Exec Time 43 ms
Memory 804 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:12:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
./Main.cpp:14:40: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
./Main.cpp:15:40: 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
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
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 19 ms 672 KB
02 AC 21 ms 800 KB
03 AC 19 ms 800 KB
04 AC 20 ms 672 KB
05 AC 19 ms 676 KB
06 AC 20 ms 668 KB
07 AC 20 ms 804 KB
08 AC 20 ms 680 KB
09 AC 20 ms 680 KB
10 AC 22 ms 752 KB
11 AC 35 ms 796 KB
12 AC 33 ms 800 KB
13 AC 35 ms 800 KB
14 AC 35 ms 796 KB
15 AC 35 ms 680 KB
16 AC 40 ms 804 KB
17 AC 41 ms 804 KB
18 AC 41 ms 800 KB
19 AC 41 ms 716 KB
20 AC 43 ms 676 KB