結果
問題 |
No.5 数字のブロック
|
ユーザー |
![]() |
提出日時 | 2017-11-06 23:42:30 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 413 bytes |
コンパイル時間 | 593 ms |
コンパイル使用メモリ | 65,324 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-24 04:10:47 |
合計ジャッジ時間 | 1,646 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 WA * 10 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> int main() { int l, n; std::vector<int> w; std::cin >> l; std::cin >> n; for (int i = 0; i < n; ++i) { int tmp; std::cin >> tmp; w.push_back(tmp); } std::sort(w.begin(), w.end()); int count = 0, sum = 0; for (; count < n || sum < l; ++count) { sum += w[count]; if (sum + w[count+1] > l) { break; } } std::cout << count+1 << "\n"; }