結果

問題 No.5 数字のブロック
ユーザー keep_OC
提出日時 2020-03-26 01:31:29
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 552 bytes
コンパイル時間 1,281 ms
コンパイル使用メモリ 166,128 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2025-01-02 00:38:25
合計ジャッジ時間 2,527 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    Int n, m;
    cin >> n >> m;
    vector<Int> a(m);
    for (Int i = 0; i < m; i++) {
        cin >> a[i];
    }
    sort(all(a));
    Int sum = 0;
    Int cnt = 0;
    for (Int i = 0; i < m; i++) {
        sum += a[i];
        if (sum <= n) {
            cnt++;
        }
    }
    dump(cnt);
    return 0;
}
0