結果

問題 No.5 数字のブロック
ユーザー ilplrr
提出日時 2017-06-19 17:18:09
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 352 bytes
コンパイル時間 476 ms
コンパイル使用メモリ 58,968 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-02 07:44:27
合計ジャッジ時間 1,481 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    int l, n;
    cin >> l >> n;

    long long w[10005]={};
    for(int i=0; i<n; i++){
        cin >> w[i];
    }

    sort(w, w+n);

    int i, sum=0;
    for(i=0; i<n && sum<=l; i++){
        sum += w[i];
    }
    cout << i-1 << endl;

    return 0;
}
0