結果

問題 No.156 キャンディー・ボックス
ユーザー 明智重蔵明智重蔵
提出日時 2015-08-28 21:22:31
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 68 ms / 2,000 ms
コード長 1,611 bytes
コンパイル時間 4,659 ms
コンパイル使用メモリ 109,672 KB
実行使用メモリ 24,024 KB
最終ジャッジ日時 2023-09-19 02:59:01
合計ジャッジ時間 7,212 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
24,024 KB
testcase_01 AC 65 ms
20,012 KB
testcase_02 AC 66 ms
21,872 KB
testcase_03 AC 65 ms
21,812 KB
testcase_04 AC 65 ms
21,888 KB
testcase_05 AC 65 ms
21,876 KB
testcase_06 AC 65 ms
21,832 KB
testcase_07 AC 66 ms
21,888 KB
testcase_08 AC 66 ms
23,908 KB
testcase_09 AC 65 ms
21,904 KB
testcase_10 AC 65 ms
21,888 KB
testcase_11 AC 65 ms
21,892 KB
testcase_12 AC 68 ms
21,876 KB
testcase_13 AC 66 ms
21,884 KB
testcase_14 AC 66 ms
21,784 KB
testcase_15 AC 65 ms
21,816 KB
testcase_16 AC 65 ms
21,952 KB
testcase_17 AC 64 ms
21,896 KB
testcase_18 AC 65 ms
23,992 KB
testcase_19 AC 66 ms
22,032 KB
testcase_20 AC 66 ms
23,960 KB
testcase_21 AC 65 ms
23,924 KB
testcase_22 AC 65 ms
22,000 KB
testcase_23 AC 65 ms
22,088 KB
testcase_24 AC 64 ms
19,868 KB
testcase_25 AC 64 ms
21,864 KB
testcase_26 AC 66 ms
24,004 KB
testcase_27 AC 65 ms
21,872 KB
testcase_28 AC 65 ms
21,864 KB
testcase_29 AC 66 ms
23,800 KB
testcase_30 AC 65 ms
22,000 KB
testcase_31 AC 65 ms
23,920 KB
testcase_32 AC 66 ms
23,924 KB
testcase_33 AC 65 ms
23,788 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "Input5";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("3 2");
            WillReturn.Add("1 2 3");
            //1
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("3 2");
            WillReturn.Add("1 1 3");
            //2
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("4 10");
            WillReturn.Add("3 2 4 1");
            //4
        }
        else if (InputPattern == "Input4") {
            WillReturn.Add("6 257109");
            WillReturn.Add("53771 46578 31908 80435 62678 4327");
            //5
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int M = InputList[0].Split(' ').Select(X => int.Parse(X)).Last();
        int[] CArr = InputList[1].Split(' ').Select(X => int.Parse(X)).ToArray();

        Array.Sort(CArr);

        int TatalCnt = 0;
        for (int I = 0; I <= CArr.GetUpperBound(0); I++) {
            TatalCnt += CArr[I];

            if (TatalCnt > M) {
                Console.WriteLine(I);
                break;
            }
            else if (TatalCnt == M) {
                Console.WriteLine(I + 1);
                break;
            }
        }
    }
}
0