結果

問題 No.527 ナップサック容量問題
コンテスト
ユーザー testestest
提出日時 2017-06-20 12:10:33
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 195 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 71 ms
コンパイル使用メモリ 25,556 KB
最終ジャッジ日時 2026-02-21 23:58:11
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.c:2:1: warning: data definition has no type or storage class
    2 | a[1<<17],*d=a+1000;
      | ^
main.c:2:1: error: type defaults to 'int' in declaration of 'a' [-Wimplicit-int]
main.c:2:11: error: type defaults to 'int' in declaration of 'd' [-Wimplicit-int]
    2 | a[1<<17],*d=a+1000;
      |           ^
main.c:3:1: warning: data definition has no type or storage class
    3 | v,w;s,j;
      | ^
main.c:3:1: error: type defaults to 'int' in declaration of 'v' [-Wimplicit-int]
main.c:3:3: error: type defaults to 'int' in declaration of 'w' [-Wimplicit-int]
    3 | v,w;s,j;
      |   ^
main.c:3:5: warning: data definition has no type or storage class
    3 | v,w;s,j;
      |     ^
main.c:3:5: error: type defaults to 'int' in declaration of 's' [-Wimplicit-int]
main.c:3:7: error: type defaults to 'int' in declaration of 'j' [-Wimplicit-int]
    3 | v,w;s,j;
      |       ^
main.c:4:1: error: return type defaults to 'int' [-Wimplicit-int]
    4 | main(t){
      | ^~~~
main.c: In function 'main':
main.c:4:1: warning: old-style function definition [-Wold-style-definition]
main.c:4:1: error: type of 't' defaults to 'int' [-Wimplicit-int]
main.c:5:15: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
    5 |         for(;~scanf("%d%d",&w,&t);j=s+=v=t)for(;j;j--)d[j]=minz(d[j],d[j-v]+w);
      |               ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | #define minz(p,q)(p&&p<q?p:q)
main.c:5:15: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
    5 |         for(;~scanf("%d%d",&w,&t);j=s+=v=t)for(;j;j--)d[j]=minz(d[j],d[j-v]+w);
      |               ^~~~~
main.c:5:15: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:6:9: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
    6 |         printf(d[t+1]?"%d\n%d":"%d\ninf",d[t]?:1,d[t+1]-1);
      |         ^~~~~

ソースコード

diff #
raw source code

#define minz(p,q)(p&&p<q?p:q)
a[1<<17],*d=a+1000;
v,w;s,j;
main(t){
	for(;~scanf("%d%d",&w,&t);j=s+=v=t)for(;j;j--)d[j]=minz(d[j],d[j-v]+w);
	printf(d[t+1]?"%d\n%d":"%d\ninf",d[t]?:1,d[t+1]-1);
}
0