結果

問題 No.5 数字のブロック
ユーザー n.yn.y
提出日時 2022-05-25 10:37:50
言語 C#
(.NET 8.0.203)
結果
WA  
実行時間 -
コード長 1,406 bytes
コンパイル時間 10,505 ms
コンパイル使用メモリ 159,780 KB
実行使用メモリ 175,556 KB
最終ジャッジ日時 2023-10-20 19:08:35
合計ジャッジ時間 12,597 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
30,888 KB
testcase_01 AC 58 ms
30,888 KB
testcase_02 AC 58 ms
30,892 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 58 ms
30,892 KB
testcase_21 AC 58 ms
30,892 KB
testcase_22 AC 57 ms
30,896 KB
testcase_23 AC 57 ms
30,896 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 56 ms
30,892 KB
testcase_27 AC 57 ms
30,896 KB
testcase_28 AC 56 ms
30,892 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 56 ms
30,888 KB
testcase_32 AC 57 ms
30,892 KB
testcase_33 AC 57 ms
175,556 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (105 ms)。
MSBuild のバージョン 17.7.3+8ec440e68 (.NET)
  main -> /home/judge/data/code/bin/Release/net7.0/main.dll
  main -> /home/judge/data/code/bin/Release/net7.0/publish/

ソースコード

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 < N; 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