結果

問題 No.5 数字のブロック
ユーザー legosuke
提出日時 2017-01-18 10:57:58
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 292 bytes
コンパイル時間 508 ms
コンパイル使用メモリ 60,348 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-23 00:55:25
合計ジャッジ時間 1,596 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    int L, N, W[10000], sum = 0, ans = 0;
    cin >> L >> N;
    for(int i=0; i<N; i++) cin >> W[i];
    sort(W, W+N);
    while(sum+W[ans]<=L) {
        sum += W[ans];
        ans++;
    }
    cout << ans << endl;
}
0