結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
zazaboon
|
| 提出日時 | 2015-08-06 19:47:06 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 426 bytes |
| コンパイル時間 | 109 ms |
| コンパイル使用メモリ | 21,120 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-18 03:42:06 |
| 合計ジャッジ時間 | 2,606 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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]);
| ^~~~~~~~~~~~~~~~~
ソースコード
#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",N);
}
return 0;
}
zazaboon