結果

問題 No.5 数字のブロック
ユーザー rinrinta121
提出日時 2019-04-01 02:39:04
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 399 bytes
コンパイル時間 630 ms
コンパイル使用メモリ 71,724 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-24 00:53:00
合計ジャッジ時間 1,773 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 8 WA * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main()
{
    int n,k;
    cin >> n >> k;
    int a[n];
    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