結果

問題 No.156 キャンディー・ボックス
ユーザー the10hoursthe10hours
提出日時 2015-06-12 22:16:40
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 92 ms / 2,000 ms
コード長 1,102 bytes
コンパイル時間 2,736 ms
コンパイル使用メモリ 101,704 KB
実行使用メモリ 22,808 KB
最終ジャッジ日時 2023-09-18 19:37:10
合計ジャッジ時間 6,244 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
20,784 KB
testcase_01 AC 59 ms
18,732 KB
testcase_02 AC 60 ms
22,716 KB
testcase_03 AC 60 ms
20,656 KB
testcase_04 AC 59 ms
20,620 KB
testcase_05 AC 61 ms
18,656 KB
testcase_06 AC 61 ms
20,660 KB
testcase_07 AC 62 ms
22,720 KB
testcase_08 AC 61 ms
22,692 KB
testcase_09 AC 61 ms
20,664 KB
testcase_10 AC 61 ms
20,628 KB
testcase_11 AC 62 ms
20,628 KB
testcase_12 AC 65 ms
22,776 KB
testcase_13 AC 61 ms
20,732 KB
testcase_14 AC 61 ms
20,660 KB
testcase_15 AC 61 ms
18,796 KB
testcase_16 AC 61 ms
22,808 KB
testcase_17 AC 62 ms
18,756 KB
testcase_18 AC 61 ms
20,620 KB
testcase_19 AC 60 ms
18,672 KB
testcase_20 AC 60 ms
20,848 KB
testcase_21 AC 61 ms
22,708 KB
testcase_22 AC 61 ms
20,780 KB
testcase_23 AC 60 ms
20,728 KB
testcase_24 AC 60 ms
22,732 KB
testcase_25 AC 59 ms
22,716 KB
testcase_26 AC 61 ms
20,624 KB
testcase_27 AC 61 ms
20,724 KB
testcase_28 AC 61 ms
18,624 KB
testcase_29 AC 60 ms
18,556 KB
testcase_30 AC 66 ms
22,708 KB
testcase_31 AC 62 ms
20,620 KB
testcase_32 AC 91 ms
18,780 KB
testcase_33 AC 92 ms
20,772 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;
using System.Text;

namespace yukicoder
{
    class yc
    {
        static void Main()
        {
            string[] str1 = Console.ReadLine().Split(' ');
            string[] str2 = Console.ReadLine().Split(' ');
            
            int N = int.Parse(str1[0]);//N = 箱の数
            int M = int.Parse(str1[1]);//M = 取りだすキャンディーの数
            int[] C = new int[N];//C = 各箱の中のキャンディーの数
            int cout = 0;

            for (int i = 0; i < N; i++)
            {
                C[i] = int.Parse(str2[i]);
            }
            
            //var c = C.Where(n=> true).OrderBy(n=>n).Select(n=>n);
            
            Array.Sort(C);
            
            for (int i = 0; i < N && M != 0; i++)
            {
                for (int j = 0; C[i] != 0 && M != 0; j++)
                {
                    C[i]--;
                    M--;
                }
                if (C[i] == 0) cout++;
            }
            Console.WriteLine(cout);
        }
    }
}
0