結果

問題 No.5 数字のブロック
ユーザー siguma323siguma323
提出日時 2016-05-03 18:34:08
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 500 bytes
コンパイル時間 538 ms
コンパイル使用メモリ 71,448 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-18 08:32:46
合計ジャッジ時間 1,454 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <numeric>
#include <string>
#include <vector>
#include <iostream>
#include <queue>
#include <utility>
#include <cmath>
using namespace std;

using ull = unsigned long long;

int main()
{
    int l,n;
    cin >> l >> n;
    vector<int> w(n);

    for(auto&& x : w) cin >> x;

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

    int count = 0;
    for(auto&& x : w)
    {
        if(l-x >= 0)
        {
            l -= x;
            ++count;
        }
    }

    cout << count << endl;
}
0