結果

問題 No.5 数字のブロック
ユーザー shimashima_kshimashima_k
提出日時 2015-04-25 12:29:53
言語 C++11
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 613 bytes
コンパイル時間 483 ms
コンパイル使用メモリ 61,160 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-05 02:19:19
合計ジャッジ時間 2,242 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>

using namespace std;

int main() {
    int L, N, ans = 0;
    vector<int> W;
    cin >> L;
    cin >> N;

    while (N--) {
        int a;
        cin>>a;
        W.push_back(a);
    }

    for (int i=0; i<W.size(); i++){
        for (int j= W.size() - 1; j > i; j--) {
            if (W[i] > W[j]){
                int t = W[i];
                W[i] = W[j];
                W[j] = t;
            }
        }
    }

    for (int i=0; i<W.size(); i++) {
        if (L > W[i]) {
            L -= W[i];
            ans++;
        }
    }



    cout<<ans<<endl;
    return 0;
}
0