結果

問題 No.5 数字のブロック
ユーザー n.yn.y
提出日時 2022-05-25 14:09:42
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,413 bytes
コンパイル時間 835 ms
コンパイル使用メモリ 108,620 KB
実行使用メモリ 25,020 KB
最終ジャッジ日時 2023-10-20 19:11:33
合計ジャッジ時間 4,330 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
24,156 KB
testcase_01 AC 22 ms
24,156 KB
testcase_02 AC 22 ms
24,156 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 22 ms
24,156 KB
testcase_21 AC 22 ms
24,156 KB
testcase_22 AC 22 ms
24,156 KB
testcase_23 AC 22 ms
24,156 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 23 ms
24,156 KB
testcase_27 AC 23 ms
24,156 KB
testcase_28 AC 23 ms
24,156 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 22 ms
24,156 KB
testcase_32 AC 23 ms
24,156 KB
testcase_33 AC 23 ms
24,156 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

namespace yukicoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //大きな箱の幅
            int L = int.Parse(Console.ReadLine());
            //箱の数
            int N = int.Parse(Console.ReadLine());

            string[] str = Console.ReadLine().Split(' ');

            int[] a = new int[str.Length];
            //各箱の幅
            for (int i = 0; i < a.Length; i++)
            {
               int W = int.Parse(str[i]);
                a[i] = W;
            }

            //小さい順
            for (int j = 0; j < a.Length; j++)
            {
                if(j==a.Length)
                {
                    a[j] = a.Length;
                }
                for (int i = 0; i < j; i++)
                {
                    if (a[i] > a[i + 1])
                    {
                        int temp = a[i];
                        a[i] = a[i + 1];
                        a[i + 1] = temp;
                    }


                }
            }

            //判定
            int num = L;
            int count = 0;
            for (int i = 0; i < str.Length; i++)
            {
                if (num >= 0 && num >= a[i])
                {
                    num = num - a[i];
                    count++;
                }

            }

            Console.WriteLine(count.ToString());





        }
    }
}
0