結果

問題 No.156 キャンディー・ボックス
ユーザー fujitafujita
提出日時 2023-05-11 10:25:15
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 53 ms / 2,000 ms
コード長 1,366 bytes
コンパイル時間 10,109 ms
コンパイル使用メモリ 142,604 KB
実行使用メモリ 161,544 KB
最終ジャッジ日時 2023-08-18 06:45:56
合計ジャッジ時間 13,367 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
28,672 KB
testcase_01 AC 51 ms
28,688 KB
testcase_02 AC 51 ms
28,800 KB
testcase_03 AC 51 ms
28,612 KB
testcase_04 AC 52 ms
28,568 KB
testcase_05 AC 52 ms
28,508 KB
testcase_06 AC 52 ms
28,684 KB
testcase_07 AC 51 ms
28,544 KB
testcase_08 AC 51 ms
28,776 KB
testcase_09 AC 53 ms
28,600 KB
testcase_10 AC 51 ms
28,660 KB
testcase_11 AC 52 ms
28,744 KB
testcase_12 AC 52 ms
28,672 KB
testcase_13 AC 52 ms
28,660 KB
testcase_14 AC 52 ms
30,636 KB
testcase_15 AC 51 ms
30,620 KB
testcase_16 AC 52 ms
28,680 KB
testcase_17 AC 51 ms
28,772 KB
testcase_18 AC 50 ms
28,620 KB
testcase_19 AC 51 ms
28,452 KB
testcase_20 AC 50 ms
28,716 KB
testcase_21 AC 52 ms
28,660 KB
testcase_22 AC 52 ms
28,732 KB
testcase_23 AC 51 ms
28,900 KB
testcase_24 AC 48 ms
28,600 KB
testcase_25 AC 48 ms
28,360 KB
testcase_26 AC 50 ms
28,556 KB
testcase_27 AC 50 ms
28,616 KB
testcase_28 AC 50 ms
28,708 KB
testcase_29 AC 50 ms
28,748 KB
testcase_30 AC 51 ms
28,768 KB
testcase_31 AC 50 ms
28,624 KB
testcase_32 AC 50 ms
28,600 KB
testcase_33 AC 52 ms
161,544 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  Determining projects to restore...
  Restored /home/judge/data/code/main.csproj (in 194 ms).
.NET 向け Microsoft (R) Build Engine バージョン 17.0.0-preview-21470-01+cb055d28f
Copyright (C) Microsoft Corporation.All rights reserved.

  プレビュー版の .NET を使用しています。https://aka.ms/dotnet-core-preview をご覧ください
  main -> /home/judge/data/code/bin/Release/net6.0/main.dll
  main -> /home/judge/data/code/bin/Release/net6.0/publish/

ソースコード

diff #

using System.Collections.Generic;
using System;
using System.Drawing;
namespace yukicoder
{
    class Program
    {

        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split(" ");
            int N = int.Parse(s[0]);
            int M = int.Parse(s[1]);

            var str = Console.ReadLine().Split(" ");
            int[] ints = new int[N];
            int box = 0;
            
            for(int i = 0; i < N; i++)
            {
                ints[i] = int.Parse(str[i]);
            }

            Array.Sort(ints);
            for(int j = 0; j < N; j++)
            {
                if (M > 0)
                {
                    M = M - ints[j];
                    if (M > 0)
                    {
                        box = box + 1;
                    }
                    else if (M <= 0)
                    {
                        if(M == 0)
                        {
                            box = box + 1;
                            Console.WriteLine(box);
                            break;
                        }
                        else
                        {
                            Console.WriteLine(box);
                            break;
                        }
                        
                    }
                }
            }
            
        }
    }
}
0