結果

問題 No.5 数字のブロック
ユーザー vrjfsyi
提出日時 2018-04-14 20:09:58
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 645 bytes
コンパイル時間 670 ms
コンパイル使用メモリ 76,448 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-26 22:34:55
合計ジャッジ時間 1,730 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <array>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <math.h>

using namespace std;

int main() {

    int L;
    int N;
    cin >> L;
    cin >> N;
    vector<int> v(N);
    int w;
    for (int i = 0; i < N; ++i) {
        cin >> w;
        v[i] = w;
    }

    sort(v.begin(), v.end());

    int result = 0;

    for (int j = 0; j < N; ++j) {
        if ((L - v[j]) > 0) {
            L -= v[j];
            result += 1;
        } else {
            result = j;
            break;
        }
    }

    cout << result << "\n";
}
0