結果

問題 No.2753 鳩の巣原理
ユーザー 👑 kakel-sankakel-san
提出日時 2024-05-23 00:23:51
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 86 ms / 2,000 ms
コード長 1,699 bytes
コンパイル時間 8,633 ms
コンパイル使用メモリ 168,132 KB
実行使用メモリ 46,040 KB
平均クエリ数 11.00
最終ジャッジ日時 2024-05-23 00:24:05
合計ジャッジ時間 12,921 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
45,152 KB
testcase_01 AC 76 ms
45,020 KB
testcase_02 AC 74 ms
45,664 KB
testcase_03 AC 75 ms
45,664 KB
testcase_04 AC 76 ms
45,516 KB
testcase_05 AC 73 ms
45,916 KB
testcase_06 AC 74 ms
45,660 KB
testcase_07 AC 75 ms
45,664 KB
testcase_08 AC 76 ms
45,280 KB
testcase_09 AC 73 ms
45,400 KB
testcase_10 AC 77 ms
45,400 KB
testcase_11 AC 76 ms
45,528 KB
testcase_12 AC 86 ms
45,776 KB
testcase_13 AC 74 ms
45,144 KB
testcase_14 AC 73 ms
45,656 KB
testcase_15 AC 74 ms
46,040 KB
testcase_16 AC 73 ms
45,520 KB
testcase_17 AC 73 ms
45,656 KB
testcase_18 AC 75 ms
45,272 KB
testcase_19 AC 75 ms
45,504 KB
testcase_20 AC 72 ms
45,248 KB
testcase_21 AC 74 ms
45,272 KB
testcase_22 AC 81 ms
45,552 KB
testcase_23 AC 73 ms
44,920 KB
testcase_24 AC 74 ms
45,248 KB
testcase_25 AC 75 ms
45,528 KB
testcase_26 AC 75 ms
45,400 KB
testcase_27 AC 75 ms
45,660 KB
testcase_28 AC 75 ms
46,040 KB
testcase_29 AC 74 ms
45,272 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (99 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
  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 static System.Console;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    static long[] LList(long n) => Enumerable.Repeat(0, (int)n).Select(_ => long.Parse(ReadLine())).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var n = NN;
        var min = 0;
        var icnt = 1;
        var max = n - 1;
        var acnt = n - 1;
        var query = 0;
        var i = 0;
        var j = 0;
        while (true)
        {
            var mid = (max + min) / 2;
            WriteLine($"? {mid + 1}");
            var dcnt = NN;
            ++query;
            if (max - min <= 2)
            {
                if (min == mid)
                {
                    i = mid;
                    j = max;
                }
                else if (icnt == dcnt)
                {
                    i = min;
                    j = mid;
                }
                else
                {
                    i = mid;
                    j = max;
                }
                break;
            }
            if (mid - min <= dcnt - icnt)
            {
                min = mid;
                icnt = dcnt;
            }
            else
            {
                max = mid;
                acnt = dcnt;
            }
        }
        while (query < 10)
        {
            WriteLine("? 1");
            ReadLine();
            ++query;
        }
        WriteLine($"Yes {i + 1} {j + 1}");
    }
}
0