結果
問題 | No.5 数字のブロック |
ユーザー | f843nmfwisfeuw |
提出日時 | 2020-06-20 08:44:21 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 5 ms / 5,000 ms |
コード長 | 669 bytes |
コンパイル時間 | 892 ms |
コンパイル使用メモリ | 98,344 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-03 16:50:20 |
合計ジャッジ時間 | 2,090 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <cmath> #include <iomanip> #include <stack> #include <algorithm> #include <string> #include <map> #include <iterator> #include <set> #include <queue> using namespace std; int main() { int L; int N; cin >> L >> N; vector<int> ws; for (int i = 0; i < N; ++i) { int W; cin >> W; ws.push_back(W); } sort(ws.begin(), ws.end()); int cnt = 0; for (int i = 0; i < N; ++i) { if (L - ws[i] >= 0) { L -= ws[i]; cnt += 1; } else { break; } } cout << cnt << endl; return 0; }