結果

問題 No.5 数字のブロック
ユーザー cakecatz
提出日時 2019-12-15 03:48:13
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 381 bytes
コンパイル時間 2,110 ms
コンパイル使用メモリ 171,964 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-28 12:52:59
合計ジャッジ時間 2,787 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main()
{
    int L;
    cin >> L;
    int N;
    cin >> N;
    vector<int> W(N);
    for (int i = 0; i < N; i++) {
        cin >> W[i];
    }
    sort(W.begin(), W.end(), less<int>());
    int ans = 0;
    for (; ans < N; ++ans) {
        L -= W[ans];
        if (L < 0)
            break;
    }

    cout << ans;

    return 0;
}
0