結果

問題 No.5 数字のブロック
ユーザー mell1mell1
提出日時 2018-11-22 18:24:45
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 666 bytes
コンパイル時間 361 ms
コンパイル使用メモリ 52,076 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-26 03:56:18
合計ジャッジ時間 3,004 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#define N 10000
using namespace std;
void sort(int n, int a[]) {
    int i, j, tmp;
    for (i=0; i<=n-2; i++) {
        for (j=i+1; j<n; j++) {
            if (a[i] > a[j]) {
                tmp = a[i];
                a[i] = a[j];
                a[j] = tmp;
            }
        }
    }
}
int main() {
    int i, width, n, a[N], sum=0, count=0;
    cin >> width >> n;
    for (i=0; i<n; i++) {
        cin >> a[i];
    }
    sort(n, a);
    while (sum <= width) {
        sum += a[count];
        count++;
        if (count == n) break;
    }
    if (count != n) sum -= a[--count];
    cout << count << endl;
    return 0;
}
0