結果

問題 No.5 数字のブロック
ユーザー rinrinta121rinrinta121
提出日時 2019-04-01 02:41:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 398 bytes
コンパイル時間 575 ms
コンパイル使用メモリ 72,888 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-03 03:51:59
合計ジャッジ時間 3,042 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;

int main()
{
    int n,k;
    cin >> n >> k;
    int a[k];
    int cnt = 0;
    for(int i = 0; i < k; i++){
        cin >> a[i];
    }
    sort(a,a+n);
    for(int i = 0; i < k; i++){
        n -= a[i];
        if(n < 0){
            break;
        }
        cnt++;
    }
    cout << cnt << endl;
}
0