結果

問題 No.27 板の準備
ユーザー cielciel
提出日時 2015-07-14 16:47:12
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 350 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 21,248 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-08 07:13:33
合計ジャッジ時間 701 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 4 ms
5,376 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 3 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:2:1: warning: data definition has no type or storage class
    2 | B[999],V[4],X[4],T,R,i,j,r;main(){
      | ^
main.c:2:1: warning: type defaults to ‘int’ in declaration of ‘B’ [-Wimplicit-int]
main.c:2:8: warning: type defaults to ‘int’ in declaration of ‘V’ [-Wimplicit-int]
    2 | B[999],V[4],X[4],T,R,i,j,r;main(){
      |        ^
main.c:2:13: warning: type defaults to ‘int’ in declaration of ‘X’ [-Wimplicit-int]
    2 | B[999],V[4],X[4],T,R,i,j,r;main(){
      |             ^
main.c:2:18: warning: type defaults to ‘int’ in declaration of ‘T’ [-Wimplicit-int]
    2 | B[999],V[4],X[4],T,R,i,j,r;main(){
      |                  ^
main.c:2:20: warning: type defaults to ‘int’ in declaration of ‘R’ [-Wimplicit-int]
    2 | B[999],V[4],X[4],T,R,i,j,r;main(){
      |                    ^
main.c:2:22: warning: type defaults to ‘int’ in declaration of ‘i’ [-Wimplicit-int]
    2 | B[999],V[4],X[4],T,R,i,j,r;main(){
      |                      ^
main.c:2:24: warning: type defaults to ‘int’ in declaration of ‘j’ [-Wimplicit-int]
    2 | B[999],V[4],X[4],T,R,i,j,r;main(){
      |                        ^
main.c:2:26: warning: type defaults to ‘int’ in declaration of ‘r’ [-Wimplicit-int]
    2 | B[999],V[4],X[4],T,R,i,j,r;main(){
      |                          ^
main.c:2:28: warning: return type defaults to ‘int’ [-Wimplicit-int]
    2 | B[999],V[4],X[4],T,R,i,j,r;main(){
      |                            ^~~~
main.c: In function ‘main’:
main.c:3:25: warning: implicit declaration of function ‘scanf’ [-Wimplicit-function-declaration]
    3 |         for(i=0;i<4;i++)scanf("%d",&V[i]),T+=V[i];R=T;
      |                         ^~~~~
main.c:1:1: note: include ‘<stdio.h>’ or provide a declaration of ‘scanf’
  +++ |+#include <stdio.h>
    1 | #define Z(i)for(X[i]=X[i-1]+1;X[i]<31;X[i]++)
main.c:3:25: warning: incompatible implicit declaration of built-in function ‘scanf’ [-Wbuiltin

ソースコード

diff #

#define Z(i)for(X[i]=X[i-1]+1;X[i]<31;X[i]++)
B[999],V[4],X[4],T,R,i,j,r;main(){
	for(i=0;i<4;i++)scanf("%d",&V[i]),T+=V[i];R=T;
	Z(1)Z(2)Z(3){
		for(j=0;j<=T;j++)B[j]=!j;
		for(i=1;i<4;i++)for(j=X[i];j<=T;j++)if(B[j-X[i]]&&(!B[j]||B[j]>B[j-X[i]]))B[j]=B[j-X[i]]+1;
		for(i=r=0;i<4&&B[V[i]];)r+=B[V[i++]]-1;
		if(i>3&&R>r)R=r;
	}
	printf("%d\n",R);
}
0