結果

問題 No.527 ナップサック容量問題
ユーザー 👑 testestest
提出日時 2017-06-20 11:20:04
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 202 bytes
コンパイル時間 288 ms
コンパイル使用メモリ 29,824 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-02 03:32:36
合計ジャッジ時間 1,764 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 37
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:1:1: warning: data definition has no type or storage class
    1 | d[1<<17];
      | ^
main.c:1:1: warning: type defaults to 'int' in declaration of 'd' [-Wimplicit-int]
main.c:2:1: warning: data definition has no type or storage class
    2 | v,w,t;j,f;
      | ^
main.c:2:1: warning: type defaults to 'int' in declaration of 'v' [-Wimplicit-int]
main.c:2:3: warning: type defaults to 'int' in declaration of 'w' [-Wimplicit-int]
    2 | v,w,t;j,f;
      |   ^
main.c:2:5: warning: type defaults to 'int' in declaration of 't' [-Wimplicit-int]
    2 | v,w,t;j,f;
      |     ^
main.c:2:7: warning: data definition has no type or storage class
    2 | v,w,t;j,f;
      |       ^
main.c:2:7: warning: type defaults to 'int' in declaration of 'j' [-Wimplicit-int]
main.c:2:9: warning: type defaults to 'int' in declaration of 'f' [-Wimplicit-int]
    2 | v,w,t;j,f;
      |         ^
main.c:3:1: warning: return type defaults to 'int' [-Wimplicit-int]
    3 | main(i){
      | ^~~~
main.c: In function 'main':
main.c:3:1: warning: type of 'i' defaults to 'int' [-Wimplicit-int]
main.c:4:15: warning: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
    4 |         for(;~scanf("%d%d",&w,&t);v=t)for(j=100010;j>=w;j--)d[j]=fmax(d[j],d[j-w]+v);
      |               ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | d[1<<17];
main.c:4:15: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
    4 |         for(;~scanf("%d%d",&w,&t);v=t)for(j=100010;j>=w;j--)d[j]=fmax(d[j],d[j-w]+v);
      |               ^~~~~
main.c:4:15: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:4:66: warning: implicit declaration of function 'fmax' [-Wimplicit-function-declaration]
    4 |         for(;~scanf("%d%d",&w,&t);v=t)for(j=100010;j>=w;j--)d[j]=fmax(d[j],d[j-w]+v);
      |                                                                  ^

ソースコード

diff #
プレゼンテーションモードにする

d[1<<17];
v,w,t;j,f;
main(i){
for(;~scanf("%d%d",&w,&t);v=t)for(j=100010;j>=w;j--)d[j]=fmax(d[j],d[j-w]+v);
for(;i<100000;f|d[i]<t&&f<1|d[i+1]<=d[f]?++i:printf("%d\n",i,f=f?-1:i));
~f&&puts("inf");
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0