結果

問題 No.5 数字のブロック
ユーザー maine_honzuki
提出日時 2020-05-03 13:29:12
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 327 bytes
コンパイル時間 1,916 ms
コンパイル使用メモリ 168,484 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-11 20:54:00
合計ジャッジ時間 2,896 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    int L, N, W[10010];
    cin >> L >> N;
    for (int i = 0; i < N; i++)
        cin >> W[i];
    sort(W, W + N);
    int ans = 0;
    while (ans < N) {
        if (L < W[ans])
            break;
        L -= W[ans];
        ans++;
    }
    cout << ans << endl;
}
0