結果

問題 No.5 数字のブロック
ユーザー nanatutmcnanatutmc
提出日時 2019-09-20 01:06:16
言語 C
(gcc 12.3.0)
結果
RE  
実行時間 -
コード長 734 bytes
コンパイル時間 119 ms
コンパイル使用メモリ 28,860 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-29 16:00:56
合計ジャッジ時間 4,111 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 AC 0 ms
4,376 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 0 ms
4,376 KB
testcase_29 RE -
testcase_30 RE -
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 1 ms
4,380 KB
testcase_33 AC 0 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:3:1: 警告: 戻り値の型をデフォルトの ‘int’ にします [-Wimplicit-int]
    3 | main() {
      | ^~~~
main.c: 関数 ‘main’ 内:
main.c:34:13: 警告: 非 void を戻す関数内に値が無い ‘return’ があります
   34 |             return;
      |             ^~~~~~
main.c:3:1: 備考: ここで宣言されています
    3 | main() {
      | ^~~~

ソースコード

diff #

#include <stdio.h>

main() {
    int L, N;
    int width[10000];
    scanf("%d", &L);
    scanf("%d", &N);
    
    for (int i=0; i<N; i++) {
        scanf("%d", &(width[i]));
    }
    
    // sort
    while (1) {
        int flag = 0;
        for (int i=0; i<N-1; i++) {
            if (width[i] > width[i+1]) {
                int tmp = width[i];
            
                width[i] = width[i+1];
                width[i+1] = tmp;
                flag = 1;
            }
        }
        if (flag == 0)
            break;
    }
    
    int total = 0;
    for (int i = 0; i<N; i++) {
        total += width[i];
        if (total > L) {
            printf("%d\n", i);
            return;
        }
    }
    printf("%d\n", N);
}
0