結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
|
| 提出日時 | 2022-02-24 16:10:58 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 8 ms / 5,000 ms |
| コード長 | 327 bytes |
| コンパイル時間 | 2,307 ms |
| コンパイル使用メモリ | 196,228 KB |
| 最終ジャッジ日時 | 2025-01-28 01:35:40 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
int x, n;
cin >> x >> n;
vector <int> arr(n);
for(auto &ele: arr) cin >> ele;
sort(arr.begin(), arr.end());
int ans = 0, tot = 0;
for(auto ele: arr){
if(tot + ele <= x){
tot += ele;
ans++;
}
}
cout << ans << "\n";
return 0;
}