結果

問題 No.2710 How many more?
ユーザー bluemeganebluemegane
提出日時 2024-04-04 16:42:51
言語 C#
(.NET 8.0.203)
結果
WA  
実行時間 -
コード長 1,139 bytes
コンパイル時間 9,215 ms
コンパイル使用メモリ 158,464 KB
実行使用メモリ 180,752 KB
最終ジャッジ日時 2024-04-04 16:43:06
合計ジャッジ時間 11,709 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
33,316 KB
testcase_01 AC 78 ms
33,316 KB
testcase_02 AC 188 ms
63,576 KB
testcase_03 WA -
testcase_04 AC 189 ms
56,232 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 108 ms
43,684 KB
testcase_08 AC 117 ms
43,940 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 153 ms
55,600 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 80 ms
180,752 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (99 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.Linq;
using static System.Math;
using System;

public class P
{
    public int id { get; set; }
    public int d { get; set; }
    public int p { get; set; }
}

public class Hello
{
    static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var q = int.Parse(line[1]);
        line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        getAns(n, q, a);
    }
    static void getAns(int n, int q, int[] a)
    {
        var ps = new P[n];
        for (int i = 0; i < n; i++) ps[i] = new P { id = i, d = a[i] };
        ps = ps.OrderBy(x => x.d).ToArray();
        for (int i = 0; i < n; i++) ps[i].p = i;
        ps = ps.OrderBy(x => x.id).ToArray();
        var ans = new int[q];
        for (int i = 0; i < q; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var xx = int.Parse(line[0]) - 1;
            var yy = int.Parse(line[1]) - 1;
            ans[i] = Max(0, ps[xx].p - ps[yy].p - 1);
        }
        Console.WriteLine(string.Join("\n", ans));
    }
}
0