結果

問題 No.5 数字のブロック
ユーザー VangaroooYamada
提出日時 2021-09-06 13:12:20
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 472 bytes
コンパイル時間 1,022 ms
コンパイル使用メモリ 75,736 KB
実行使用メモリ 6,816 KB
最終ジャッジ日時 2024-12-22 19:16:11
合計ジャッジ時間 2,286 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    int L, N;
    cin >> L >> N;
    
    vector<int> W(N, 0);
    
    for (int w=0; w < N; ++w) {
        cin >> W.at(w);
    }
    sort(W.begin(), W.end());
    
    int sum_len = 0;
    
    for (int w=0; w < N; ++w) {
        sum_len += W[w];
        if (L < sum_len) {
            cout << w << endl;
            return 0;
        }    
    }
    
    cout << N << endl;
}
0