結果

問題 No.5 数字のブロック
ユーザー pepe
提出日時 2017-06-10 14:23:03
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 413 bytes
コンパイル時間 615 ms
コンパイル使用メモリ 22,904 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-24 20:27:20
合計ジャッジ時間 2,041 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,372 KB
testcase_01 AC 0 ms
4,372 KB
testcase_02 WA -
testcase_03 AC 45 ms
4,372 KB
testcase_04 AC 27 ms
4,372 KB
testcase_05 AC 82 ms
4,372 KB
testcase_06 AC 29 ms
4,372 KB
testcase_07 AC 19 ms
4,372 KB
testcase_08 AC 39 ms
4,372 KB
testcase_09 AC 4 ms
4,372 KB
testcase_10 AC 99 ms
4,372 KB
testcase_11 AC 17 ms
4,372 KB
testcase_12 AC 50 ms
4,372 KB
testcase_13 AC 78 ms
4,372 KB
testcase_14 AC 1 ms
4,372 KB
testcase_15 AC 1 ms
4,372 KB
testcase_16 AC 86 ms
4,372 KB
testcase_17 AC 123 ms
4,372 KB
testcase_18 AC 107 ms
4,372 KB
testcase_19 AC 138 ms
4,372 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 1 ms
4,372 KB
testcase_24 AC 1 ms
4,372 KB
testcase_25 AC 1 ms
4,372 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 26 ms
4,372 KB
testcase_30 AC 6 ms
4,372 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:5:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    5 |         scanf("%d%d",&l,&n);
      |         ~~~~~^~~~~~~~~~~~~~
main.cpp:7:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |                 scanf("%d",&w[i]);
      |                 ~~~~~^~~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>
int l,n,w[10000],p,s,y,m,i;
int main()
{
	scanf("%d%d",&l,&n);
	for(i=0;i<n;i++){
		scanf("%d",&w[i]);
	}
	do{s=0;
		for(i=0;i<n-p;i++){
			if(w[i]>w[i+1]){
				w[i]^=w[i+1];
				w[i+1]^=w[i];
				w[i]^=w[i+1];
				s=1;
			}
		}
		p++;
		//puts("石倉");
	}while(s!=0);
	for(i=0;i<n;i++){
		if((y+w[i])>l){
			break;
		}
		if(w[i]>0){
			y+=w[i];
			m++;
		}
	}
	printf("%d\n",m);
	return 0;	
}
0