結果

問題 No.5 数字のブロック
ユーザー ReERishunReERishun
提出日時 2019-06-05 10:13:43
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,203 bytes
コンパイル時間 305 ms
コンパイル使用メモリ 33,572 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 23:22:07
合計ジャッジ時間 4,353 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 WA -
testcase_03 AC 145 ms
4,348 KB
testcase_04 AC 96 ms
4,348 KB
testcase_05 WA -
testcase_06 AC 100 ms
4,348 KB
testcase_07 AC 70 ms
4,348 KB
testcase_08 AC 130 ms
4,348 KB
testcase_09 AC 18 ms
4,348 KB
testcase_10 AC 279 ms
4,348 KB
testcase_11 AC 66 ms
4,348 KB
testcase_12 AC 157 ms
4,348 KB
testcase_13 AC 230 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 WA -
testcase_16 AC 250 ms
4,348 KB
testcase_17 AC 342 ms
4,348 KB
testcase_18 AC 299 ms
4,348 KB
testcase_19 AC 380 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 AC 3 ms
4,348 KB
testcase_26 WA -
testcase_27 AC 2 ms
4,348 KB
testcase_28 AC 1 ms
4,348 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 2 ms
4,348 KB
testcase_32 AC 2 ms
4,348 KB
testcase_33 AC 2 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