Submission #330130


Source Code Expand

#include<bits/stdc++.h>

using namespace std;

int q,m,k,i,j;

int T[2005],S[2005];

int DP[1000005],Q[1000005];

int main(){

   memset(Q,10,sizeof Q);

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

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

   for(i=1 ; i<=k ; i++)
      scanf("%d",S+i);

   DP[0]=1;

   for(i=1 ; i<=m ; i++)
      for(j=150000 ; j>=0 ; j--)
         if(DP[j] and (Q[j]==168430090 or Q[j]+T[i]<=q) ){
            DP[T[i]+j]=1;
            if(Q[j]==168430090)
               Q[T[i]+j]=T[i];
            else
               Q[T[i]+j]=min(Q[T[i]+j],Q[j]+T[i]);
         }

   for(i=1 ; i<=k ; i++)
      for(j=150000 ; j>=0 ; j--)
         if(DP[j] and (Q[j]==168430090 or Q[j]+S[i]<=q) ){
            DP[S[i]+j-1]=1;
            if(Q[j]==168430090)
               Q[T[i]+j]=S[i];
            else
               Q[S[i]+j]=min(Q[S[i]+j],Q[j]+S[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 1003 Byte
Status WA
Exec Time 1033 ms
Memory 5288 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:15:30: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
./Main.cpp:18:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
./Main.cpp:21: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
WA × 1
WA × 1
WA × 1
WA × 1
WA × 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 42 ms 4764 KB
02 WA 45 ms 4640 KB
03 WA 33 ms 4640 KB
04 WA 33 ms 4640 KB
05 WA 33 ms 4648 KB
06 WA 50 ms 4644 KB
07 WA 50 ms 4636 KB
08 WA 51 ms 4640 KB
09 WA 51 ms 4636 KB
10 WA 52 ms 4768 KB
11 WA 828 ms 4836 KB
12 WA 884 ms 5088 KB
13 WA 877 ms 5020 KB
14 WA 879 ms 5020 KB
15 WA 878 ms 5028 KB
16 TLE 1032 ms 5276 KB
17 TLE 1033 ms 5276 KB
18 TLE 1033 ms 5284 KB
19 TLE 1033 ms 5288 KB
20 WA 775 ms 5280 KB