結果
問題 |
No.5 数字のブロック
|
ユーザー |
|
提出日時 | 2024-07-18 23:18:51 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 404 bytes |
コンパイル時間 | 2,592 ms |
コンパイル使用メモリ | 249,944 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-18 23:18:55 |
合計ジャッジ時間 | 3,479 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(void) { ios::sync_with_stdio(false); cin.tie(nullptr); int l, n; cin >> l >> n; vector<int> w(n); for (int i = 0; i < n; ++i) cin >> w[i]; sort(w.begin(), w.end()); int res = 0, cnt = 0; for (auto x: w) { res += x; if (res > l) break; cnt++; } cout << cnt << '\n'; return 0; }