結果
問題 |
No.156 キャンディー・ボックス
|
ユーザー |
![]() |
提出日時 | 2015-06-12 22:16:40 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 57 ms / 2,000 ms |
コード長 | 1,102 bytes |
コンパイル時間 | 1,163 ms |
コンパイル使用メモリ | 103,936 KB |
実行使用メモリ | 18,048 KB |
最終ジャッジ日時 | 2024-07-05 09:16:20 |
合計ジャッジ時間 | 3,179 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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; 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); } } }