結果
問題 |
No.5 数字のブロック
|
ユーザー |
![]() |
提出日時 | 2019-01-11 19:37:03 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 442 bytes |
コンパイル時間 | 168 ms |
コンパイル使用メモリ | 22,784 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-29 16:56:28 |
合計ジャッジ時間 | 1,022 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 WA * 10 |
コンパイルメッセージ
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; 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; } } L=L-W[x]; if(L<0){ break; } } printf("%d\n",x); return 0; }