結果
問題 |
No.5 数字のブロック
|
ユーザー |
![]() |
提出日時 | 2018-11-30 09:55:47 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 378 bytes |
コンパイル時間 | 237 ms |
コンパイル使用メモリ | 36,836 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-26 23:08:01 |
合計ジャッジ時間 | 1,165 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | WA * 34 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:9:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | scanf("%d %d",&L,&N); | ~~~~~^~~~~~~~~~~~~~~ main.cpp:11:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | scanf("%d",&W[i]); | ~~~~~^~~~~~~~~~~~
ソースコード
#include<cstdio> #include<algorithm> int main(){ int W[10000]; int L,N,i; int max = 0; int sum = 0; scanf("%d %d",&L,&N); for(i = 0; i < N; i++){ scanf("%d",&W[i]); } std::sort(W,W + N); for(i=0;i<N;i++){ sum += W[i]; if(sum <= L){ max++; }else break; } printf("%d/n",max); return 0; }