結果
問題 | No.156 キャンディー・ボックス |
ユーザー |
![]() |
提出日時 | 2015-02-26 23:38:05 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 27 ms / 2,000 ms |
コード長 | 872 bytes |
コンパイル時間 | 790 ms |
コンパイル使用メモリ | 108,744 KB |
実行使用メモリ | 18,176 KB |
最終ジャッジ日時 | 2024-07-05 08:39:21 |
合計ジャッジ時間 | 2,612 ms |
ジャッジサーバーID (参考情報) |
judge2 / 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;class program{public static void Main(){var str = Console.ReadLine().Split(' ');var N = int.Parse(str[0]);var M = int.Parse(str[1]);str = Console.ReadLine().Split(' ');var C = new int[str.Length];for (int i = 0; i < str.Length; i++){C[i] = int.Parse(str[i]);}Array.Sort(C);for (int i = 0; i < C.Length; i++){if (M - C[i] >= 0){M -= C[i];C[i] = 0;}else{C[i] -= M;M = 0;break;}}var count = 0;foreach (var i in C){if (i == 0) count++;}Console.WriteLine(count);}}