結果

問題 No.5 数字のブロック
ユーザー satanic
提出日時 2016-04-04 22:04:39
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 425 bytes
コンパイル時間 706 ms
コンパイル使用メモリ 74,768 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-04 00:59:32
合計ジャッジ時間 1,646 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 14 WA * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    
    int L, N, ans=0;
    std::cin >> L >> N;
    std::vector<int> W(N);
    for(int i=0; i<N; ++i){
        std::cin >> W[i];
    }
    std::sort(W.begin(), W.end(), std::less<int>());
    for(;ans<N && L>0; ++ans){
        L -= W[ans];
    }
    std::cout << ans << "\n";

    return 0;
}
0