Submission #330277


Source Code Expand

#include<bits/stdc++.h>

using namespace std;

#define pb push_back

int n,m,k,j,i,x,t,q,kalan,qwe;

int N[4005];

int DP[5000005];

bool H[4005];

vector<int> V;

int main(){

   scanf("%d %d %d",&q,&m,&k);

   for(i=1 ; i<=m ; i++)
      scanf("%d",N+i);

   for(i=1 ; i<=k ; i++){
      scanf("%d",&x);
      V.pb(x);
   }

   sort(N+1,N+m+1);

   DP[0]=INT_MAX;

   for(i=1 ; i<=m ; i++)
      for(j=150000 ; j>=0 ; j--)
         if(DP[j] and !DP[j+N[i]])
            DP[j+N[i]]=i;

   for(i=q ; i>=0 ; i--)
      if(DP[i]){

         qwe=i;

         t=DP[i];

         while(1){
            H[t]=1;
            i=i-N[t];
            t=DP[i];
            if(t==INT_MAX)
               break;
         }

         break;
      }

   for(i=1 ; i<=m ; i++)
      if(!H[i])
         V.pb(N[i]);

   sort(V.begin(),V.end());

   kalan=q-qwe;

   if(kalan){

      for(i=V.size()-1 ; i>=0 ; i--){
         if(kalan>=V[i]){
            qwe+=V[i]-1;
            kalan-=V[i];
            if(!kalan)
               break;
         }
         else {
            qwe+=kalan-1;
            kalan=0;
            break;
         }
      }
   }

   cout<<qwe;

   return 0;
}

Submission Info

Submission Time
Task 14 - Farmer
User berasogut
Language C++ (G++ 4.6.4)
Score 0
Code Size 1249 Byte
Status WA
Exec Time 450 ms
Memory 1320 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:19:30: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
./Main.cpp:22:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
./Main.cpp:25:21: 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
RE × 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 RE 269 ms 804 KB
02 WA 31 ms 808 KB
03 WA 25 ms 924 KB
04 WA 25 ms 800 KB
05 WA 25 ms 800 KB
06 WA 31 ms 804 KB
07 WA 32 ms 804 KB
08 WA 33 ms 932 KB
09 WA 30 ms 804 KB
10 WA 30 ms 800 KB
11 WA 336 ms 1056 KB
12 WA 334 ms 1056 KB
13 WA 334 ms 1060 KB
14 WA 337 ms 1068 KB
15 WA 335 ms 1064 KB
16 WA 448 ms 1056 KB
17 WA 448 ms 1048 KB
18 WA 450 ms 1056 KB
19 WA 450 ms 1060 KB
20 WA 423 ms 1320 KB