結果
問題 | No.156 キャンディー・ボックス |
ユーザー |
|
提出日時 | 2022-06-03 11:16:57 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 29 ms / 2,000 ms |
コード長 | 874 bytes |
コンパイル時間 | 800 ms |
コンパイル使用メモリ | 110,164 KB |
実行使用メモリ | 26,460 KB |
最終ジャッジ日時 | 2024-09-21 02:16:42 |
合計ジャッジ時間 | 2,705 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; namespace yukicoder { class Program { static void Main(string[] args) { string[] s = Console.ReadLine().Split(' '); string[] s1 = Console.ReadLine().Split(' '); int a = int.Parse(s[0]); int b = int.Parse(s[1]); int[] c = new int[a]; int count = 0; for(int x = 0; x < a; x++) { c[x] = int.Parse(s1[x]); } Array.Sort(c); for (int i = 0; i < a; i++) { if ( b-c[i]>=0 ) { b = b - c[i]; count++; } if (b < 0) { break; } } Console.WriteLine(count); } } }