結果
問題 | No.527 ナップサック容量問題 |
ユーザー | 👑 testestest |
提出日時 | 2017-06-09 22:32:49 |
言語 | C (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 9 ms / 2,000 ms |
コード長 | 388 bytes |
コンパイル時間 | 105 ms |
コンパイル使用メモリ | 29,824 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-22 15:18:54 |
合計ジャッジ時間 | 1,309 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 1 ms
6,940 KB |
testcase_03 | AC | 1 ms
6,944 KB |
testcase_04 | AC | 1 ms
6,944 KB |
testcase_05 | AC | 5 ms
6,940 KB |
testcase_06 | AC | 8 ms
6,940 KB |
testcase_07 | AC | 7 ms
6,940 KB |
testcase_08 | AC | 4 ms
6,940 KB |
testcase_09 | AC | 2 ms
6,940 KB |
testcase_10 | AC | 8 ms
6,940 KB |
testcase_11 | AC | 6 ms
6,940 KB |
testcase_12 | AC | 5 ms
6,940 KB |
testcase_13 | AC | 8 ms
6,940 KB |
testcase_14 | AC | 4 ms
6,944 KB |
testcase_15 | AC | 6 ms
6,944 KB |
testcase_16 | AC | 2 ms
6,944 KB |
testcase_17 | AC | 5 ms
6,944 KB |
testcase_18 | AC | 5 ms
6,944 KB |
testcase_19 | AC | 2 ms
6,944 KB |
testcase_20 | AC | 4 ms
6,940 KB |
testcase_21 | AC | 9 ms
6,944 KB |
testcase_22 | AC | 7 ms
6,944 KB |
testcase_23 | AC | 9 ms
6,940 KB |
testcase_24 | AC | 3 ms
6,940 KB |
testcase_25 | AC | 6 ms
6,940 KB |
testcase_26 | AC | 6 ms
6,940 KB |
testcase_27 | AC | 5 ms
6,944 KB |
testcase_28 | AC | 5 ms
6,940 KB |
testcase_29 | AC | 9 ms
6,940 KB |
testcase_30 | AC | 3 ms
6,944 KB |
testcase_31 | AC | 5 ms
6,940 KB |
testcase_32 | AC | 5 ms
6,940 KB |
testcase_33 | AC | 5 ms
6,944 KB |
testcase_34 | AC | 5 ms
6,944 KB |
testcase_35 | AC | 5 ms
6,940 KB |
testcase_36 | AC | 1 ms
6,944 KB |
testcase_37 | AC | 4 ms
6,940 KB |
testcase_38 | AC | 6 ms
6,940 KB |
testcase_39 | AC | 5 ms
6,940 KB |
コンパイルメッセージ
main.c:2:1: warning: data definition has no type or storage class 2 | d[200000]; | ^ main.c:2:1: warning: type defaults to 'int' in declaration of 'd' [-Wimplicit-int] main.c:3:1: warning: data definition has no type or storage class 3 | v[110],w[110],n; | ^ main.c:3:1: warning: type defaults to 'int' in declaration of 'v' [-Wimplicit-int] main.c:3:8: warning: type defaults to 'int' in declaration of 'w' [-Wimplicit-int] 3 | v[110],w[110],n; | ^ main.c:3:15: warning: type defaults to 'int' in declaration of 'n' [-Wimplicit-int] 3 | v[110],w[110],n; | ^ main.c:4:1: warning: data definition has no type or storage class 4 | i,j,t,m; | ^ main.c:4:1: warning: type defaults to 'int' in declaration of 'i' [-Wimplicit-int] main.c:4:3: warning: type defaults to 'int' in declaration of 'j' [-Wimplicit-int] 4 | i,j,t,m; | ^ main.c:4:5: warning: type defaults to 'int' in declaration of 't' [-Wimplicit-int] 4 | i,j,t,m; | ^ main.c:4:7: warning: type defaults to 'int' in declaration of 'm' [-Wimplicit-int] 4 | i,j,t,m; | ^ main.c:5:1: warning: return type defaults to 'int' [-Wimplicit-int] 5 | main(){ | ^~~~ main.c: In function 'main': main.c:6:5: warning: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 6 | scanf("%d",&n); | ^~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf' +++ |+#include <stdio.h> 1 | #define max(p,q)(p>q?p:q) main.c:6:5: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] 6 | scanf("%d",&n); | ^~~~~ main.c:6:5: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:10:38: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration] 10 | for(i=1;i<100000;i++)if(d[i]>=t){printf("%d\n",m=i);break;} | ^~~~~~
ソースコード
#define max(p,q)(p>q?p:q) d[200000]; v[110],w[110],n; i,j,t,m; main(){ scanf("%d",&n); for(i=0;i<n;i++)scanf("%d%d",v+i,w+i); for(i=0;i<n;i++)for(j=100000;j>=w[i];j--)d[j]=max(d[j],d[j-w[i]]+v[i]); scanf("%d",&t); for(i=1;i<100000;i++)if(d[i]>=t){printf("%d\n",m=i);break;} for(;i<=100000;i++)if(d[i]>d[m]){printf("%d\n",i-1);return 0;} puts("inf");return 0; }