結果

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

ソースコード

diff #

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

int main() {
    int n, l,a, sum=0;
    priority_queue<int, vector<int>, greater<> > Q;
    cin >> l >> n;
    for (int i = 0; i < n; ++i) {scanf("%d", &a); Q.push(a);}
    a = -1;
    while (!Q.empty() && sum < l){
        sum += Q.top(); Q.pop();
        a++;
    }
    cout << a << "\n";
    return 0;
}
0