結果

問題 No.5 数字のブロック
ユーザー DrakkonDrakkon
提出日時 2018-02-07 18:51:04
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 671 bytes
コンパイル時間 1,130 ms
コンパイル使用メモリ 28,716 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-10-14 22:26:55
合計ジャッジ時間 4,877 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 1 ms
4,352 KB
testcase_03 AC 112 ms
4,352 KB
testcase_04 AC 70 ms
4,352 KB
testcase_05 AC 189 ms
4,352 KB
testcase_06 AC 75 ms
4,352 KB
testcase_07 AC 51 ms
4,348 KB
testcase_08 AC 98 ms
4,352 KB
testcase_09 AC 12 ms
4,348 KB
testcase_10 AC 225 ms
4,348 KB
testcase_11 AC 48 ms
4,352 KB
testcase_12 AC 122 ms
4,352 KB
testcase_13 AC 182 ms
4,352 KB
testcase_14 AC 0 ms
4,348 KB
testcase_15 AC 1 ms
4,352 KB
testcase_16 AC 199 ms
4,356 KB
testcase_17 AC 279 ms
4,348 KB
testcase_18 AC 241 ms
4,352 KB
testcase_19 AC 312 ms
4,352 KB
testcase_20 WA -
testcase_21 AC 1 ms
4,348 KB
testcase_22 AC 0 ms
4,348 KB
testcase_23 AC 0 ms
4,348 KB
testcase_24 AC 1 ms
4,348 KB
testcase_25 AC 2 ms
4,352 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 69 ms
4,356 KB
testcase_30 AC 16 ms
4,356 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
int main(void){
    int L, N, W[10000], i, j, t;
    unsigned long long sum= 0;
    scanf("%d%d", &L, &N);
    for(i = 0; i < N; i++){
        scanf("%d", &W[i]);
    }
    do{
        j = 0;
        for(i = 1; i < N; i++){
            if(W[i - 1] > W[i]){
                t = W[i - 1];
                W[i - 1] = W[i];
                W[i] = t;
                j++;
            }
        }
    }while(j != 0);
    while(sum <= L && N != 0){
        sum += W[j];
        j++;
        N--;
    }
    if(sum != L){
        printf("%d\n", j - 1);
    }
    else if(sum == L){
        printf("%d\n", j);
    }
    return 0;
}
0