結果

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

ソースコード

diff #

#include<stdio.h>
int main(void)
{
	int i,L,N,W[10001],W_h,j,ans=0,sum=0;	
	scanf("%d",&L);
	scanf("%d",&N);
	for(i=0;i<N;i++)
	{
		scanf("%d",&W[i]);
	}	
	for(j=0;j<N;j++)
	{
		for(i=0;i<(N-1);i++)
		{
			if(W[i]>W[i+1])
			{
				W_h = W[i];
				W[i] = W[i+1];
				W[i+1] = W_h;
			}
		}
	}
	while(sum<L)
	{
		sum = sum + W[ans];
		ans++;
	}
	if(ans<N)
	{
		printf("%d",ans-1);
	}
	else
	{
		printf("%d",N);
	}
}
0