結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 87 ms
5,376 KB
testcase_04 AC 56 ms
5,376 KB
testcase_05 AC 142 ms
5,376 KB
testcase_06 AC 60 ms
5,376 KB
testcase_07 AC 43 ms
5,376 KB
testcase_08 AC 77 ms
5,376 KB
testcase_09 AC 14 ms
5,376 KB
testcase_10 AC 167 ms
5,376 KB
testcase_11 AC 39 ms
5,376 KB
testcase_12 AC 94 ms
5,376 KB
testcase_13 AC 135 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 3 ms
5,376 KB
testcase_16 AC 147 ms
5,376 KB
testcase_17 AC 203 ms
5,376 KB
testcase_18 AC 180 ms
5,376 KB
testcase_19 AC 227 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 AC 1 ms
5,376 KB
testcase_29 AC 55 ms
5,376 KB
testcase_30 AC 16 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 1 ms
5,376 KB
testcase_33 AC 1 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;
                        }
                }
        }
        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) ? 1 : i-1) << endl;
        return 0;
}
0