結果
問題 | No.5 数字のブロック |
ユーザー | mizakura |
提出日時 | 2017-04-07 17:06:47 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 5 ms / 5,000 ms |
コード長 | 454 bytes |
コンパイル時間 | 700 ms |
コンパイル使用メモリ | 74,712 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-18 10:59:22 |
合計ジャッジ時間 | 1,746 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
#include <iostream> #include <algorithm> #include <vector> int main() { int l, n; int sum = 0; int count = 0; std::cin >> l >> n; std::vector<int> w; for (int i = 0; i < n; i++) { int t; std::cin >> t; w.push_back(t); } std::sort(w.begin(), w.end()); for (auto itr = w.begin(); itr != w.end(); itr++) { sum += *itr; if (sum > l) { break; } count++; } std::cout << count << std::endl; return 0; }