結果

問題 No.5 数字のブロック
ユーザー ksbaseball
提出日時 2021-04-03 17:17:35
言語 C++17(clang)
(17.0.6 + boost 1.87.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 472 bytes
コンパイル時間 1,784 ms
コンパイル使用メモリ 165,072 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-25 03:02:05
合計ジャッジ時間 2,722 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 33 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int box, block;
    cin >> box; cin >> block;
    int b[block];
    for(int i = 0; i < block; i++){
        cin >> b[i];
    }
    
    int total = 0;
    int output = 0;
    
    sort(b, b + block);

    while(total <= box){
        total += b[output];
        output += 1; 
    }
    if(total <= box){
        cout << output << endl;
    }
    else{
        cout << output-1 << endl;
    }
    return 0;
}
0