結果
問題 | No.156 キャンディー・ボックス |
ユーザー |
|
提出日時 | 2019-01-29 23:04:43 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 218 ms / 2,000 ms |
コード長 | 757 bytes |
コンパイル時間 | 964 ms |
コンパイル使用メモリ | 109,196 KB |
実行使用メモリ | 27,364 KB |
最終ジャッジ日時 | 2024-07-05 16:24:07 |
合計ジャッジ時間 | 3,517 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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)); } }