結果

問題 No.5 数字のブロック
ユーザー fumi6328
提出日時 2018-06-30 22:32:08
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 449 bytes
コンパイル時間 208 ms
コンパイル使用メモリ 23,168 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-01 01:02:11
合計ジャッジ時間 2,490 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 34
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:11:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |         scanf("%d",&L);
      |         ~~~~~^~~~~~~~~
main.cpp:12:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |         scanf("%d",&N);
      |         ~~~~~^~~~~~~~~
main.cpp:14:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   14 |                 scanf("%d",&W[i]);
      |                 ~~~~~^~~~~~~~~~~~
main.cpp:27:22: warning: ‘judge’ is used uninitialized [-Wuninitialized]
   27 |         for(k=0;judge>0;++k){
      |                 ~~~~~^~

ソースコード

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