結果

問題 No.5 数字のブロック
ユーザー DrakkonDrakkon
提出日時 2018-02-07 18:36:27
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 610 bytes
コンパイル時間 692 ms
コンパイル使用メモリ 28,484 KB
実行使用メモリ 4,484 KB
最終ジャッジ日時 2023-10-14 13:30:07
合計ジャッジ時間 4,901 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 0 ms
4,352 KB
testcase_02 WA -
testcase_03 AC 131 ms
4,348 KB
testcase_04 AC 82 ms
4,348 KB
testcase_05 AC 220 ms
4,352 KB
testcase_06 AC 88 ms
4,352 KB
testcase_07 AC 59 ms
4,352 KB
testcase_08 AC 115 ms
4,352 KB
testcase_09 AC 14 ms
4,356 KB
testcase_10 AC 262 ms
4,348 KB
testcase_11 AC 55 ms
4,348 KB
testcase_12 AC 141 ms
4,352 KB
testcase_13 AC 211 ms
4,352 KB
testcase_14 AC 1 ms
4,352 KB
testcase_15 AC 1 ms
4,348 KB
testcase_16 AC 231 ms
4,352 KB
testcase_17 AC 323 ms
4,348 KB
testcase_18 AC 280 ms
4,348 KB
testcase_19 AC 364 ms
4,348 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 1 ms
4,348 KB
testcase_24 AC 1 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 80 ms
4,348 KB
testcase_30 AC 18 ms
4,352 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, 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){
        sum += W[j];
        j++;
    }
    if(sum != L){
        printf("%d\n", j - 1);
    }
    else{
        printf("%d\n", j);
    }
    return 0;
}
0