結果

問題 No.5 数字のブロック
ユーザー firiexp
提出日時 2018-07-16 18:54:26
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 439 bytes
コンパイル時間 860 ms
コンパイル使用メモリ 73,824 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-18 12:32:09
合計ジャッジ時間 1,925 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <queue>
using ll = long long;
using namespace std;

int main() {
    int n, l,a, sum=0, j = 0;
    priority_queue<int, vector<int>, greater<> > Q;
    cin >> l >> n;
    for (int i = 0; i < n; ++i) {scanf("%d", &a); Q.push(a);}

    for (; !Q.empty();) {
        a = Q.top(); Q.pop();
        if(a + sum <= l){
            sum += a; j++;
        }
    }
    cout << j << "\n";
    return 0;
}
0