Submission #330172


Source Code Expand

#include<bits/stdc++.h>

using namespace std;

int q,m,k,i,j,kalan;

int N[2005],R[2005];

int DP[1000005],Q[1000005];

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",R+i);

   DP[0]=1;

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

            if(Q[j]+N[i]>q){

               kalan=q-Q[j];

               DP[j+kalan-1]=1;
               Q[j+kalan-1]=q;

               continue;
            }

            DP[j+N[i]]=1;
            if(!Q[j+N[i]])
               Q[j+N[i]]=Q[j]+N[i];
            else
               Q[j+N[i]]=min(Q[j+N[i]],Q[j]+N[i]);
         }

   for(i=1 ; i<=k ; i++)
      for(j=150000 ; j>=0 ; j--)
         if(DP[j]){

            if(Q[j]+R[i]>q){

               kalan=q-Q[j];

               DP[j+kalan-1]=1;
               Q[j+kalan-1]=q;

               continue;
            }

            DP[j+R[i]]=1;
            if(!Q[j+R[i]])
               Q[j+R[i]]=Q[j]+R[i];
            else
               Q[j+R[i]]=min(Q[j+R[i]],Q[j]+R[i]);
         }

   for(i=q ; i>=0 ; i--)
      if(DP[i])
         return cout<<i,0;
   return 0;
}

Submission Info

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

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:13:30: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
./Main.cpp:16:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
./Main.cpp:20:22: 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
TLE × 1
TLE × 1
TLE × 1
TLE × 1
TLE × 1
TLE × 1
TLE × 1
TLE × 1
TLE × 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 35 ms 848 KB
02 WA 46 ms 1044 KB
03 WA 29 ms 1032 KB
04 WA 31 ms 1028 KB
05 WA 31 ms 840 KB
06 WA 48 ms 1032 KB
07 WA 48 ms 836 KB
08 WA 47 ms 840 KB
09 WA 47 ms 908 KB
10 WA 47 ms 900 KB
11 TLE 1037 ms 1416 KB
12 TLE 1037 ms 1480 KB
13 TLE 1037 ms 1604 KB
14 TLE 1037 ms 1620 KB
15 TLE 1037 ms 1736 KB
16 TLE 1035 ms 1668 KB
17 TLE 1036 ms 1812 KB
18 TLE 1041 ms 1988 KB
19 TLE 1046 ms 1940 KB
20 WA 782 ms 2012 KB