結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
zazaboon
|
| 提出日時 | 2015-08-06 20:04:18 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
AC
|
| 実行時間 | 205 ms / 5,000 ms |
| コード長 | 442 bytes |
| コンパイル時間 | 117 ms |
| コンパイル使用メモリ | 20,992 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-18 07:29:08 |
| 合計ジャッジ時間 | 2,575 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
コンパイルメッセージ
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-1)<N)
{
printf("%d",ans-1);
}
if((ans-1)>=N)
{
printf("%d\n",N);
}
return 0;
}
zazaboon