結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
|
| 提出日時 | 2024-07-21 00:08:53 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 23 ms / 5,000 ms |
| コード長 | 496 bytes |
| コンパイル時間 | 797 ms |
| コンパイル使用メモリ | 77,836 KB |
| 最終ジャッジ日時 | 2025-02-23 17:22:18 |
|
ジャッジサーバーID (参考情報) |
judge3 / 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;
}