結果

問題 No.2716 Falcon Method
ユーザー 👑 kakel-sankakel-san
提出日時 2024-04-05 22:31:01
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 240 ms / 2,000 ms
コード長 1,882 bytes
コンパイル時間 7,922 ms
コンパイル使用メモリ 157,784 KB
実行使用メモリ 212,228 KB
最終ジャッジ日時 2024-04-05 22:31:27
合計ジャッジ時間 14,550 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
32,804 KB
testcase_01 AC 76 ms
32,804 KB
testcase_02 AC 80 ms
32,804 KB
testcase_03 AC 81 ms
32,804 KB
testcase_04 AC 83 ms
32,804 KB
testcase_05 AC 79 ms
32,804 KB
testcase_06 AC 81 ms
33,572 KB
testcase_07 AC 83 ms
33,572 KB
testcase_08 AC 83 ms
33,572 KB
testcase_09 AC 83 ms
33,572 KB
testcase_10 AC 81 ms
33,572 KB
testcase_11 AC 235 ms
65,488 KB
testcase_12 AC 169 ms
60,452 KB
testcase_13 AC 157 ms
55,588 KB
testcase_14 AC 201 ms
63,592 KB
testcase_15 AC 163 ms
57,124 KB
testcase_16 AC 206 ms
63,836 KB
testcase_17 AC 210 ms
63,604 KB
testcase_18 AC 240 ms
65,568 KB
testcase_19 AC 197 ms
63,692 KB
testcase_20 AC 165 ms
56,868 KB
testcase_21 AC 207 ms
63,468 KB
testcase_22 AC 237 ms
65,576 KB
testcase_23 AC 240 ms
65,576 KB
testcase_24 AC 240 ms
65,576 KB
testcase_25 AC 81 ms
32,804 KB
testcase_26 AC 80 ms
32,804 KB
testcase_27 AC 222 ms
65,416 KB
testcase_28 AC 228 ms
212,228 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (95 ms)。
MSBuild のバージョン 17.7.3+8ec440e68 (.NET)
  main -> /home/judge/data/code/bin/Release/net7.0/main.dll
  main -> /home/judge/data/code/bin/Release/net7.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 int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray();
    static string[] SList(long n) => Enumerable.Repeat(0, (int)n).Select(_ => ReadLine()).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var c = NList;
        var (n, q) = (c[0], c[1]);
        var s = ReadLine();
        var map = NArr(q);
        var cumx = new int[n + 1];
        var cumy = new int[n + 1];
        for (var i = 0; i < n; ++i)
        {
            cumx[i + 1] = cumx[i] + (s[i] == 'D' ? 1 : 0);
            cumy[i + 1] = cumy[i] + (s[i] == 'R' ? 1 : 0);
        }
        var ans = new int[q];
        for (var i = 0; i < q; ++i)
        {
            var h = map[i][0] + cumx[map[i][2]];
            var w = map[i][1] + cumy[map[i][2]];
            var lng = -1L;
            var lok = 1_000_000_000L;
            while (lok - lng > 1)
            {
                var mid = (lok + lng) / 2;
                var mx = cumx[n] * mid;
                var my = cumy[n] * mid;
                if (mx >= h || my >= w) lok = mid;
                else lng = mid;
            }
            --lok;
            var ng = -1;
            var ok = n;
            while (ok - ng > 1)
            {
                var mid = (ok + ng) / 2;
                var mx = cumx[n] * lok + cumx[mid];
                var my = cumy[n] * lok + cumy[mid];
                if (mx >= h || my >= w) ok = mid;
                else ng = mid;
            }
            ans[i] = ok % n;
        }
        WriteLine(string.Join("\n", ans));
    }
}
0