結果

問題 No.5 数字のブロック
ユーザー コーヒー太郎コーヒー太郎
提出日時 2020-05-14 10:25:15
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 559 bytes
コンパイル時間 320 ms
コンパイル使用メモリ 29,024 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-13 02:29:33
合計ジャッジ時間 3,634 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 WA -
testcase_03 AC 95 ms
4,348 KB
testcase_04 AC 60 ms
4,348 KB
testcase_05 AC 162 ms
4,348 KB
testcase_06 AC 63 ms
4,352 KB
testcase_07 AC 43 ms
4,352 KB
testcase_08 AC 84 ms
4,348 KB
testcase_09 AC 10 ms
4,348 KB
testcase_10 AC 194 ms
4,348 KB
testcase_11 AC 40 ms
4,348 KB
testcase_12 AC 104 ms
4,352 KB
testcase_13 AC 156 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 1 ms
4,352 KB
testcase_16 AC 170 ms
4,348 KB
testcase_17 AC 240 ms
4,348 KB
testcase_18 AC 207 ms
4,352 KB
testcase_19 AC 268 ms
4,348 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 0 ms
4,348 KB
testcase_24 AC 1 ms
4,352 KB
testcase_25 AC 1 ms
4,348 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 58 ms
4,348 KB
testcase_30 AC 13 ms
4,348 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#include<stdlib.h>


int main(void){
    int L, N, a;
    int *p;

    scanf("%d %d", &L, &N);
    p = (int *)malloc(sizeof(int) * N);

    for(int i = 0; i < N; i++) scanf("%d", &p[i]);
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N - i - 1; j++){
            if(p[j] > p[j + 1]){
                a = p[j];
                p[j] = p[j + 1];
                p[j + 1] = a;
            }
        }
    }

    a = 0;
    while(L >= 0){
        L -= p[a];
        a++;
    }

    free(p);
    printf("%d\n", a - 1);

    return 0;
}
0