Submission #330183


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
Task 14 - Farmer
User Kerem
Language C++ (G++ 4.6.4)
Score 0
Code Size 1032 Byte
Status WA
Exec Time 512 ms
Memory 1308 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
WA × 1
WA × 1
WA × 1
WA × 1
WA × 1
WA × 1
WA × 1
WA × 1
WA × 1
WA × 1
WA × 1
WA × 1
WA × 1
WA × 1
WA × 1
WA × 1
WA × 1
WA × 1
WA × 1
WA × 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 WA 26 ms 736 KB
02 WA 24 ms 924 KB
03 WA 23 ms 800 KB
04 WA 24 ms 804 KB
05 WA 25 ms 932 KB
06 WA 25 ms 804 KB
07 WA 25 ms 800 KB
08 WA 24 ms 800 KB
09 WA 23 ms 800 KB
10 WA 25 ms 800 KB
11 WA 162 ms 1052 KB
12 WA 187 ms 1052 KB
13 WA 203 ms 1056 KB
14 WA 214 ms 1056 KB
15 WA 238 ms 1060 KB
16 WA 305 ms 1056 KB
17 WA 342 ms 1056 KB
18 WA 404 ms 1056 KB
19 WA 512 ms 1052 KB
20 WA 469 ms 1308 KB