結果

問題 No.3295 Buying Bottled Water
ユーザー aketijyuuzou
提出日時 2025-10-05 13:58:41
言語 C#
(.NET 8.0.404)
結果
AC  
実行時間 89 ms / 2,000 ms
コード長 1,520 bytes
コンパイル時間 8,241 ms
コンパイル使用メモリ 171,020 KB
実行使用メモリ 187,624 KB
最終ジャッジ日時 2025-10-05 13:58:51
合計ジャッジ時間 9,350 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (153 ミリ秒)。
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("700");
            //2
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("550");
            //1
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("2300");
            //5
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static long[] GetSplitArr(string pStr)
    {
        return (pStr == "" ? new string[0] : pStr.Split(' ')).Select(pX => long.Parse(pX)).ToArray();
    }

    static long mN;

    static void Main()
    {
        List<string> InputList = GetInputList();
        mN = long.Parse(InputList[0]);

        long L = 0;
        long R = mN * 500;

        if (mN < 100) {
            Console.WriteLine(0);
            return;
        }

        while (L + 1 < R) {
            long Mid = (L + R) / 2;

            if (CanAchieve(Mid)) {
                R = Mid;
            }
            else {
                L = Mid;
            }
        }
        Console.WriteLine(R);
    }

    // Xが解かを返す
    static bool CanAchieve(long pX)
    {
        long Result = mN - 500 * pX;
        return Result < 100;
    }

}
0