結果

問題 No.5 数字のブロック
ユーザー ReERishunReERishun
提出日時 2019-06-05 10:19:55
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 1,204 bytes
コンパイル時間 1,394 ms
コンパイル使用メモリ 30,560 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-19 23:30:30
合計ジャッジ時間 4,805 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 145 ms
4,348 KB
testcase_04 AC 94 ms
4,348 KB
testcase_05 AC 236 ms
4,348 KB
testcase_06 AC 99 ms
4,348 KB
testcase_07 AC 68 ms
4,348 KB
testcase_08 AC 129 ms
4,348 KB
testcase_09 AC 17 ms
4,348 KB
testcase_10 AC 280 ms
4,348 KB
testcase_11 AC 66 ms
4,348 KB
testcase_12 AC 156 ms
4,348 KB
testcase_13 AC 229 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 1 ms
4,348 KB
testcase_16 AC 248 ms
4,348 KB
testcase_17 AC 340 ms
4,348 KB
testcase_18 AC 297 ms
4,348 KB
testcase_19 AC 381 ms
4,348 KB
testcase_20 AC 1 ms
4,348 KB
testcase_21 AC 1 ms
4,348 KB
testcase_22 WA -
testcase_23 AC 1 ms
4,348 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 WA -
testcase_27 AC 1 ms
4,348 KB
testcase_28 AC 1 ms
4,348 KB
testcase_29 AC 91 ms
4,348 KB
testcase_30 AC 23 ms
4,348 KB
testcase_31 AC 1 ms
4,348 KB
testcase_32 AC 1 ms
4,348 KB
testcase_33 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {

    //箱の高さ
    int boxWidth=0;

    //ブロック個数
    int num=0;


    scanf("%d",&boxWidth);  //箱の高さ取得
    scanf("%d",&num);       //ブロックの個数取得

    int width[num+1];

    //初期化
    for(int i=0;i<num+1;i++)
        width[i]=0;

    //入力判定
    for(int i=0;i<num+1;i++){
        char numBox;
        for(int j=0;;j++){
            numBox = getchar();
            if(numBox < '0'||numBox > '9')
                break;
            else
                width[i] = width[i] * 10 + (int)numBox - (int)'0';
        }
    }

    //配列先頭の空白削除
    for(int i=0;i<num+1;i++)
        width[i]=width[i+1];

    //昇順にソート
    for(int i=0;i<num-1;i++){
        int numBox;
        for(int j=0;j<num-1;j++){
            if(width[j]>width[j+1]){
                numBox = width[j];
                width[j] = width[j+1];
                width[j+1] = numBox;
            }

        }
    }

    //答え格納変数
    int ans=0;

    //箱に格納
    for(;boxWidth >= width[ans];ans++){
        boxWidth -= width[ans];
    }

    //出力
    printf("%d\n",ans);


    return 0;
}
0