結果

問題 No.156 キャンディー・ボックス
ユーザー CleyLCleyL
提出日時 2020-01-07 23:16:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 447 bytes
コンパイル時間 761 ms
コンパイル使用メモリ 74,392 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-02 11:50:51
合計ジャッジ時間 4,000 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 2 ms
6,944 KB
testcase_04 WA -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 AC 2 ms
6,948 KB
testcase_21 WA -
testcase_22 RE -
testcase_23 WA -
testcase_24 AC 2 ms
6,940 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 2 ms
6,944 KB
testcase_29 AC 2 ms
6,948 KB
testcase_30 RE -
testcase_31 WA -
testcase_32 RE -
testcase_33 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n,m;cin>>n>>m;
    vector<int> a(n);
    for(int i = 0; n > i; i++){
        cin>>a[i];
    }
    int ans = 0;
    sort(a.begin(),a.end());
    for(int i = 0; 1; i++){
        if(m >= a[i]){
            ans++;
            a[i] = 0;
            m -= a[i];
        }else{
            cout << ans << endl;
            return 0;
        }
    }
    
}
0