結果

問題 No.5 数字のブロック
ユーザー A63295
提出日時 2015-12-19 13:50:10
言語 C90
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 431 bytes
コンパイル時間 427 ms
コンパイル使用メモリ 21,248 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-16 08:56:22
合計ジャッジ時間 2,581 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27 WA * 7
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:5:1: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    5 | scanf("%d%d", &L, &N);
      | ^~~~~~~~~~~~~~~~~~~~~
main.c:8:1: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 | scanf("%d",&W[i]);
      | ^~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
int main(void){
int i, j, tmp, L, N;
int W[10000] = {};
scanf("%d%d", &L, &N);

for( i = 0; i < N; i++){
scanf("%d",&W[i]);
}
for( i = 0; i < N - 1; ++i){
	for ( j = i + 1; j < N; ++j){
		if ( W[i] > W[j]){
			tmp = W[i];
			W[i] = W[j];
			W[j] = tmp;
	
		} 
	}
}
int goukei = 0, count = 0;
for ( i = 0; goukei < L; i++){
	goukei += W[i];
	count++;
}
if(goukei > L){
	count--;
}
printf ("%d",count);
return 0;
}
0