結果

問題 No.1454 ツブ消ししとるなEasy
ユーザー Maeda
提出日時 2025-04-08 10:58:48
言語 C#
(.NET 8.0.404)
結果
RE  
実行時間 -
コード長 1,709 bytes
コンパイル時間 7,549 ms
コンパイル使用メモリ 170,628 KB
実行使用メモリ 189,920 KB
最終ジャッジ日時 2025-04-08 10:59:00
合計ジャッジ時間 11,235 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 12 RE * 4
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (126 ミリ秒)。
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #

    class Program
    {
        static void Main(string[] args)
        {
            string[] tbutter = Console.ReadLine().Split(' ');
            string[] goodList = Console.ReadLine().Split(' ');
            int postCount = 0;
            ulong goodCount = 0;
            List<int> remainingGood = new List<int>();
            for(int i = 0; i < int.Parse(tbutter[0]); i++)
            {
                if (int.Parse(goodList[i]) >= int.Parse(tbutter[2]))
                {
                    postCount++;
                    goodCount += ulong.Parse(goodList[i]);
                }
                else if (int.Parse(goodList[i]) < int.Parse(tbutter[2]) && int.Parse(goodList[i]) > int.Parse(tbutter[3]))
                {
                    remainingGood.Add(int.Parse(goodList[i]));
                }
                if(postCount > int.Parse(tbutter[1]))
                {
                    break;
                }
            }

            if (postCount > int.Parse(tbutter[1]))
            {
                Console.WriteLine("Handicapped");
            }
            else
            {
                ShortageCount(postCount, goodCount, int.Parse(tbutter[1]), remainingGood);
            }
        }

        private static void ShortageCount(int postCount,ulong goodCount, int v, List<int> remainingGood)
        {
            if (remainingGood.Count != 0)
            {
                remainingGood = remainingGood.OrderByDescending(i => i).ToList();
                for (int i = 0; i < v - postCount; i++)
                {
                    goodCount += ulong.Parse(remainingGood[i].ToString());
                }
            }
            Console.WriteLine(goodCount);
        }
    }
0