結果
問題 |
No.5 数字のブロック
|
ユーザー |
|
提出日時 | 2017-05-03 19:38:46 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 326 bytes |
コンパイル時間 | 500 ms |
コンパイル使用メモリ | 58,620 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-14 07:08:56 |
合計ジャッジ時間 | 1,576 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | WA * 34 |
コンパイルメッセージ
main.cpp: In function ‘int main(int, const char**)’: main.cpp:22:17: warning: ‘cnt’ may be used uninitialized in this function [-Wmaybe-uninitialized] 22 | cout << cnt << endl; | ^~~
ソースコード
#include <algorithm> #include <iostream> using namespace std; int main(int argc, const char* argv[]) { int L, N; cin >> L >> N; int W[N]; for (auto&& w : W) cin >> w; sort(W, &W[N]); int cnt; int sum = 0; for (auto&& w : W) { sum += w; if (sum > L) { break; } cnt++; } cout << cnt << endl; return 0; }