結果

問題 No.5 数字のブロック
ユーザー かぼちゃ
提出日時 2018-04-02 12:17:00
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 384 bytes
コンパイル時間 860 ms
コンパイル使用メモリ 64,248 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-26 06:33:49
合計ジャッジ時間 2,043 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    int l,n;
    cin >> l >> n;
    vector<int> w(n);
    for(int i = 0;i < n;i++){
        cin >> w[i];
    }
    sort(w.begin(),w.end());
    int count = 0;
    while(l > 0){
        l -= w[count];
        if(l < 0)break;
        count++;
    }
    cout << count << endl;
    return 0;
}
0