結果

問題 No.247 線形計画問題もどき
ユーザー cielciel
提出日時 2015-07-17 23:00:47
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 408 bytes
コンパイル時間 550 ms
コンパイル使用メモリ 19,968 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-07 11:00:30
合計ジャッジ時間 1,314 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
6,816 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 12 ms
6,944 KB
testcase_03 AC 0 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 0 ms
6,940 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 0 ms
6,944 KB
testcase_10 AC 1 ms
6,940 KB
testcase_11 AC 0 ms
6,940 KB
testcase_12 AC 1 ms
6,944 KB
testcase_13 AC 0 ms
6,940 KB
testcase_14 AC 0 ms
6,940 KB
testcase_15 AC 0 ms
6,944 KB
testcase_16 AC 1 ms
6,944 KB
testcase_17 AC 2 ms
6,944 KB
testcase_18 AC 0 ms
6,940 KB
testcase_19 AC 6 ms
6,944 KB
testcase_20 AC 10 ms
6,940 KB
testcase_21 AC 1 ms
6,944 KB
testcase_22 AC 2 ms
6,944 KB
testcase_23 AC 1 ms
6,944 KB
testcase_24 AC 11 ms
6,940 KB
testcase_25 AC 8 ms
6,944 KB
testcase_26 AC 1 ms
6,944 KB
testcase_27 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:2:1: warning: data definition has no type or storage class
    2 | a[100],b[100000],N;
      | ^
main.c:2:1: warning: type defaults to ‘int’ in declaration of ‘a’ [-Wimplicit-int]
main.c:2:8: warning: type defaults to ‘int’ in declaration of ‘b’ [-Wimplicit-int]
    2 | a[100],b[100000],N;
      |        ^
main.c:2:18: warning: type defaults to ‘int’ in declaration of ‘N’ [-Wimplicit-int]
    2 | a[100],b[100000],N;
      |                  ^
main.c: In function ‘ite’:
main.c:3:6: warning: type of ‘n’ defaults to ‘int’ [-Wimplicit-int]
    3 | void ite(n){
      |      ^~~
main.c: At top level:
main.c:17:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
   17 | main(){
      | ^~~~
main.c: In function ‘main’:
main.c:19:9: warning: implicit declaration of function ‘scanf’ [-Wimplicit-function-declaration]
   19 |         scanf("%d%d",&C,&N);
      |         ^~~~~
main.c:1:1: note: include ‘<stdio.h>’ or provide a declaration of ‘scanf’
  +++ |+#include <stdio.h>
    1 | //icpc2010dC test using InformationScience2008[3] ite()
main.c:19:9: warning: incompatible implicit declaration of built-in function ‘scanf’ [-Wbuiltin-declaration-mismatch]
   19 |         scanf("%d%d",&C,&N);
      |         ^~~~~
main.c:19:9: note: include ‘<stdio.h>’ or provide a declaration of ‘scanf’
main.c:22:9: warning: implicit declaration of function ‘printf’ [-Wimplicit-function-declaration]
   22 |         printf("%d\n",b[C]?:-1);
      |         ^~~~~~
main.c:22:9: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
main.c:22:9: warning: incompatible implicit declaration of built-in function ‘printf’ [-Wbuiltin-declaration-mismatch]
main.c:22:9: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
main.c:23:9: warning: implicit declaration of function ‘exit’ [-Wimplicit-function-declaration]
   23 |         exit(0);
      |         ^~~~
main.c:1:1: note: inc

ソースコード

diff #

//icpc2010dC test using InformationScience2008[3] ite()
a[100],b[100000],N;
void ite(n){
	int m,k,l,i;
	b[0] = 0;
	for(m=1;m<=n;m++){
		i = 0;
		k = l = -1;
		for(i=0;i<N;i++){
			if(m >= a[i] && b[m-a[i]] >= 0 && (k < 0 || b[m-a[i]] + 1 < k))
				k = b[m-a[i]] + 1;
		}
		b[m] = k;
	}
}

main(){
	int C,i=0;
	scanf("%d%d",&C,&N);
	for(;i<N;i++)scanf("%d",a+i);
	ite(C);
	printf("%d\n",b[C]?:-1);
	exit(0);
}
0