結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
hape8810
|
| 提出日時 | 2019-01-11 19:33:24 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 196 ms / 5,000 ms |
| コード長 | 472 bytes |
| コンパイル時間 | 348 ms |
| コンパイル使用メモリ | 23,168 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-18 12:48:03 |
| 合計ジャッジ時間 | 2,683 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:5:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
5 | scanf("%d%d",&L,&N);
| ~~~~~^~~~~~~~~~~~~~
main.cpp:7:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
7 | scanf("%d",&W[x]);
| ~~~~~^~~~~~~~~~~~
ソースコード
#include <stdio.h>
int main(void){
int L,N,x,y,tmp,i;
int W[10000];
scanf("%d%d",&L,&N);
for(x=0;x<N;x++){
scanf("%d",&W[x]);
}
for(x=0;x<N-1;x++){
for(y=x;y<N;y++){
if(W[y]<W[x]){
tmp=W[y];
W[y]=W[x];
W[x]=tmp;
}
}
}
for(i=0;i<N;i++){
L=L-W[i];
if(L<0){
break;
}
}
printf("%d\n",i);
return 0;
}
hape8810