結果

問題 No.5 数字のブロック
ユーザー HimatsubushinHimatsubushin
提出日時 2019-07-15 16:12:29
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 408 ms / 5,000 ms
コード長 1,221 bytes
コンパイル時間 2,608 ms
コンパイル使用メモリ 101,512 KB
実行使用メモリ 23,396 KB
最終ジャッジ日時 2023-08-18 05:41:30
合計ジャッジ時間 8,384 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 59 ms
20,716 KB
testcase_01 AC 58 ms
20,620 KB
testcase_02 AC 58 ms
20,728 KB
testcase_03 AC 199 ms
21,040 KB
testcase_04 AC 106 ms
20,984 KB
testcase_05 AC 278 ms
21,092 KB
testcase_06 AC 156 ms
21,144 KB
testcase_07 AC 128 ms
20,988 KB
testcase_08 AC 175 ms
21,252 KB
testcase_09 AC 81 ms
23,016 KB
testcase_10 AC 282 ms
21,200 KB
testcase_11 AC 119 ms
23,044 KB
testcase_12 AC 211 ms
21,060 KB
testcase_13 AC 254 ms
21,300 KB
testcase_14 AC 60 ms
22,744 KB
testcase_15 AC 66 ms
20,880 KB
testcase_16 AC 285 ms
21,136 KB
testcase_17 AC 377 ms
23,396 KB
testcase_18 AC 316 ms
21,232 KB
testcase_19 AC 408 ms
21,384 KB
testcase_20 AC 60 ms
22,784 KB
testcase_21 AC 59 ms
20,612 KB
testcase_22 AC 59 ms
20,800 KB
testcase_23 AC 60 ms
22,708 KB
testcase_24 AC 68 ms
20,864 KB
testcase_25 AC 67 ms
18,768 KB
testcase_26 AC 60 ms
20,884 KB
testcase_27 AC 58 ms
22,748 KB
testcase_28 AC 59 ms
20,800 KB
testcase_29 AC 104 ms
21,112 KB
testcase_30 AC 85 ms
22,964 KB
testcase_31 AC 60 ms
22,832 KB
testcase_32 AC 60 ms
22,696 KB
testcase_33 AC 57 ms
20,660 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 No005_数字のブロック
{
    class Program
    {
        static private int l;
        static private int n;
        static private int max = 0;

        static public void Main(string[] args)
        {

            l = int.Parse(Console.ReadLine());
            n = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');
            int[] w = new int[n];
            int ww = 0;

            for (int i = 0; i < n; i++)
                w[i] = int.Parse(input[i]);

            Sort(ref w);

            foreach(int a in w)
            {
                ww += a;
                if (ww <= l)
                    max++;
                else
                    break;
            }

            Console.WriteLine(max);
        }

        static private void Sort(ref int[] data)
        {
            for (int i = 0; i < data.Length - 1; i++)
                for (int j = i; j < data.Length; j++)
                    if (data[i] > data[j])
                        Swap(ref data[i], ref data[j]);
        }

        static private void Swap(ref int a, ref int b)
        {
            int temp = a;
            a = b;
            b = temp;
        }
    }
}
0