結果

問題 No.156 キャンディー・ボックス
ユーザー CleyLCleyL
提出日時 2020-01-07 23:17:54
言語 cLay
(20240104-1)
結果
WA  
実行時間 -
コード長 447 bytes
コンパイル時間 1,584 ms
コンパイル使用メモリ 162,816 KB
実行使用メモリ 5,260 KB
最終ジャッジ日時 2023-09-19 00:34:30
合計ジャッジ時間 3,552 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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++;
            m -= a[i];
            a[i] = 0;
        }else{
            cout << ans << endl;
            return 0;
        }
    }
    
}
0