結果

問題 No.156 キャンディー・ボックス
ユーザー CroweaCrowea
提出日時 2019-01-29 23:04:43
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 268 ms / 2,000 ms
コード長 757 bytes
コンパイル時間 1,185 ms
コンパイル使用メモリ 63,932 KB
実行使用メモリ 25,852 KB
最終ジャッジ日時 2023-09-19 03:47:48
合計ジャッジ時間 5,256 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
21,836 KB
testcase_01 AC 65 ms
23,920 KB
testcase_02 AC 64 ms
19,844 KB
testcase_03 AC 63 ms
21,836 KB
testcase_04 AC 64 ms
21,748 KB
testcase_05 AC 69 ms
21,840 KB
testcase_06 AC 75 ms
23,712 KB
testcase_07 AC 72 ms
21,920 KB
testcase_08 AC 71 ms
23,920 KB
testcase_09 AC 69 ms
23,896 KB
testcase_10 AC 72 ms
21,828 KB
testcase_11 AC 70 ms
19,836 KB
testcase_12 AC 75 ms
23,780 KB
testcase_13 AC 72 ms
25,852 KB
testcase_14 AC 70 ms
23,716 KB
testcase_15 AC 73 ms
21,792 KB
testcase_16 AC 70 ms
23,896 KB
testcase_17 AC 71 ms
21,720 KB
testcase_18 AC 66 ms
23,884 KB
testcase_19 AC 66 ms
23,888 KB
testcase_20 AC 63 ms
21,876 KB
testcase_21 AC 64 ms
23,788 KB
testcase_22 AC 66 ms
23,884 KB
testcase_23 AC 66 ms
23,900 KB
testcase_24 AC 63 ms
21,872 KB
testcase_25 AC 61 ms
21,748 KB
testcase_26 AC 63 ms
21,808 KB
testcase_27 AC 63 ms
21,836 KB
testcase_28 AC 64 ms
21,872 KB
testcase_29 AC 62 ms
21,760 KB
testcase_30 AC 95 ms
21,740 KB
testcase_31 AC 73 ms
21,844 KB
testcase_32 AC 268 ms
21,936 KB
testcase_33 AC 267 ms
21,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

class Program
{
    static void Main(string[] args)
    {
        var line = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
        int n = line[0];
        int m = line[1];

        var candy = new List<int>(n);
        candy = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
        candy.Sort();

        int takeCnt = 0;
        int idx = 0;
        while (idx < candy.Count())
        {
            if (candy[idx] > 0)
            {
                if (takeCnt == m) { break; }
                takeCnt++;
                candy[idx]--;
            }
            else idx++;
        }
        Console.WriteLine(candy.Count(x => x == 0));
    }
}



0