結果

問題 No.5 数字のブロック
ユーザー kyuna
提出日時 2019-08-04 11:14:24
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 338 bytes
コンパイル時間 757 ms
コンパイル使用メモリ 75,968 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-07 22:46:43
合計ジャッジ時間 1,534 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int l, n; cin >> l >> n;
    vector<int> w(n);
    for (int &wi: w) cin >> wi;
    sort(w.rbegin(), w.rend());
    int sum = 0;
    while (sum + w.back() <= l) sum += w.back(), w.pop_back();
    cout << n - w.size() << endl;
    return 0;
}
0