結果

問題 No.5 数字のブロック
ユーザー naniwha12naniwha12
提出日時 2019-01-29 00:33:47
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 802 bytes
コンパイル時間 488 ms
コンパイル使用メモリ 54,228 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 10:57:23
合計ジャッジ時間 2,768 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 64 ms
5,376 KB
testcase_04 AC 39 ms
5,376 KB
testcase_05 AC 109 ms
5,376 KB
testcase_06 AC 42 ms
5,376 KB
testcase_07 AC 28 ms
5,376 KB
testcase_08 AC 56 ms
5,376 KB
testcase_09 AC 7 ms
5,376 KB
testcase_10 AC 132 ms
5,376 KB
testcase_11 AC 26 ms
5,376 KB
testcase_12 AC 68 ms
5,376 KB
testcase_13 AC 104 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 116 ms
5,376 KB
testcase_17 AC 163 ms
5,376 KB
testcase_18 AC 141 ms
5,376 KB
testcase_19 AC 183 ms
5,376 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 1 ms
5,376 KB
testcase_27 WA -
testcase_28 AC 1 ms
5,376 KB
testcase_29 AC 38 ms
5,376 KB
testcase_30 AC 9 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
int l, n;
void
sort(int* a) {
        int t;
        int i, f = 1;
        while (f && n >= 0) {
                f = 0;
                for (i = 0; i < n-1; i++) {
                        if (a[i] > a[i+1]) {
                                a[i]   ^= a[i+1];
                                a[i+1] ^= a[i];
                                a[i]   ^= a[i+1];
                                f = 1;
                        }
                }
        }
}
int
main() {
        cin >> l >> n;
        int w[n];
        int i;
        for (i = 0; i < n; i++) cin >> w[i];
        sort(w); // 小さい順(昇順)
        for (i = 0; l >= 0; i++)
                l -= w[i];
        if (l = 0) cout << i << endl;
        else cout << i-1 << endl;
        return 0;
}
0