結果

問題 No.5 数字のブロック
ユーザー fumi6328
提出日時 2018-06-30 22:40:21
言語 C90
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 420 bytes
コンパイル時間 761 ms
コンパイル使用メモリ 20,736 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-01 01:02:29
合計ジャッジ時間 3,101 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 34
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:11:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |         scanf("%d",&L);
      |         ^~~~~~~~~~~~~~
main.c:12:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |         scanf("%d",&N);
      |         ^~~~~~~~~~~~~~
main.c:14:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   14 |                 scanf("%d",&W[i]);
      |                 ^~~~~~~~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>

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