結果
問題 | No.5 数字のブロック |
ユーザー |
![]() |
提出日時 | 2016-10-29 19:57:10 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 5 ms / 5,000 ms |
コード長 | 436 bytes |
コンパイル時間 | 573 ms |
コンパイル使用メモリ | 65,288 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-18 10:23:56 |
合計ジャッジ時間 | 1,568 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
#include <vector> #include <iostream> #include <algorithm> int main(int, char **) { int l; size_t n; std::vector<int> w; std::cin >> l >> n; if (n > 10000) return -1; for (int i = 0, input = 0; i < n; ++i) { std::cin >> input; w.push_back(input); } std::sort(w.begin(), w.end()); int cnt = 0; for (int i = 0, s = 0; i < w.size() && (s += w[i]) <= l; ++i) { ++cnt; } std::cout << cnt << std::endl; return 0; }