結果

問題 No.5 数字のブロック
ユーザー naniwha12naniwha12
提出日時 2019-01-29 00:39:55
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 845 bytes
コンパイル時間 537 ms
コンパイル使用メモリ 55,000 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-16 11:12:21
合計ジャッジ時間 2,993 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 WA -
testcase_03 AC 79 ms
5,376 KB
testcase_04 AC 52 ms
5,376 KB
testcase_05 AC 129 ms
5,376 KB
testcase_06 AC 55 ms
5,376 KB
testcase_07 AC 39 ms
5,376 KB
testcase_08 AC 71 ms
5,376 KB
testcase_09 AC 12 ms
5,376 KB
testcase_10 AC 158 ms
5,376 KB
testcase_11 AC 36 ms
5,376 KB
testcase_12 AC 85 ms
5,376 KB
testcase_13 AC 124 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 137 ms
5,376 KB
testcase_17 AC 187 ms
5,376 KB
testcase_18 AC 165 ms
5,376 KB
testcase_19 AC 209 ms
5,376 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 3 ms
5,376 KB
testcase_25 AC 4 ms
5,376 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 51 ms
5,376 KB
testcase_30 AC 15 ms
5,376 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

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;
                        }
                }
        }
        for (i = 0; i < n; i++) cerr << a[i] << " ";
}
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 < n; i++)
                l -= w[i];
        if (l = 0) cout << i + 1 << endl;
        else cout << i-1 << endl;
        return 0;
}
0