結果
問題 | No.5 数字のブロック |
ユーザー | Vertigo |
提出日時 | 2024-07-21 00:08:53 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 5 ms / 5,000 ms |
コード長 | 496 bytes |
コンパイル時間 | 751 ms |
コンパイル使用メモリ | 80,604 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-21 00:08:58 |
合計ジャッジ時間 | 1,880 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main(){ int t, n; cin >> t >> n; vector<int> a(n); for(int i = 0; i < n; i++){ cin >> a[i]; } sort(a.begin(), a.end()); int cur = 0; int res = 0; for(int i = 0; i < n; i++) { if(cur + a[i] <= t) { cur += a[i]; res++; } else { break; } } cout << res << endl; }