結果

問題 No.5 数字のブロック
ユーザー kai10920kai10920
提出日時 2023-01-25 17:26:26
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 348 bytes
コンパイル時間 745 ms
コンパイル使用メモリ 79,052 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-26 20:57:39
合計ジャッジ時間 1,764 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    int l;
    int n;
    std::cin>>l>>n;
    std::vector<int> w(n);
    for(int& element : w){
        std::cin>>element;
    }
    std::sort(w.begin(),w.end());
    int count=0;
    while(n>count&&l>=w[count]){
        l-=w[count];
        count++;
    }
   std::cout<<count;
}
0