結果
| 問題 | No.527 ナップサック容量問題 |
| コンテスト | |
| ユーザー |
👑 tails
|
| 提出日時 | 2017-06-09 22:42:08 |
| 言語 | C(gnu17) (gcc 15.2.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 452 bytes |
| 記録 | |
| コンパイル時間 | 83 ms |
| コンパイル使用メモリ | 25,780 KB |
| 最終ジャッジ日時 | 2026-02-21 23:51:47 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.c:1:1: warning: data definition has no type or storage class
1 | v[110];
| ^
main.c:1:1: error: type defaults to 'int' in declaration of 'v' [-Wimplicit-int]
main.c:2:1: warning: data definition has no type or storage class
2 | w[110];
| ^
main.c:2:1: error: type defaults to 'int' in declaration of 'w' [-Wimplicit-int]
main.c:3:1: warning: data definition has no type or storage class
3 | n;k;
| ^
main.c:3:1: error: type defaults to 'int' in declaration of 'n' [-Wimplicit-int]
main.c:3:3: warning: data definition has no type or storage class
3 | n;k;
| ^
main.c:3:3: error: type defaults to 'int' in declaration of 'k' [-Wimplicit-int]
main.c:4:1: warning: data definition has no type or storage class
4 | d[100010][110];
| ^
main.c:4:1: error: type defaults to 'int' in declaration of 'd' [-Wimplicit-int]
main.c:5:1: warning: data definition has no type or storage class
5 | f;
| ^
main.c:5:1: error: type defaults to 'int' in declaration of 'f' [-Wimplicit-int]
main.c:7:1: error: return type defaults to 'int' [-Wimplicit-int]
7 | main(){
| ^~~~
main.c: In function 'main':
main.c:8:9: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
8 | scanf("%d",&n);
| ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
+++ |+#include <stdio.h>
1 | v[110];
main.c:8:9: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
8 | scanf("%d",&n);
| ^~~~~
main.c:8:9: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:24:25: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
24 | printf("%d\n",c-1);
| ^~~~~~
main.c:24:25: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:24:25: warning: incompatible implicit declaration of built
ソースコード
v[110];
w[110];
n;k;
d[100010][110];
f;
main(){
scanf("%d",&n);
for(int i=0;i<n;++i){
scanf("%d%d",v+i,w+i);
}
scanf("%d",&k);
for(int c=1;c<100000;++c){
for(int i=0;i<n;++i){
if(i>0){
d[c][i]=d[c][i-1];
}
if(c-w[i]>=0){
int d1=d[c-w[i]][i-1]+v[i];
if(d[c][i]<d1)d[c][i]=d1;
}
}
if(f&&d[c][n-1]>k){
printf("%d\n",c-1);
exit(0);
}
if(!f&&d[c][n-1]==k){
printf("%d\n",c);
f=1;
}
}
puts("inf");
}
tails