結果

問題 No.2710 How many more?
ユーザー OhnoHirokiOhnoHiroki
提出日時 2024-03-31 14:03:24
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 988 ms / 2,000 ms
コード長 281 bytes
コンパイル時間 508 ms
コンパイル使用メモリ 11,776 KB
実行使用メモリ 36,228 KB
最終ジャッジ日時 2024-03-31 14:03:36
合計ジャッジ時間 12,234 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
9,984 KB
testcase_01 AC 28 ms
9,984 KB
testcase_02 AC 825 ms
24,108 KB
testcase_03 AC 451 ms
24,396 KB
testcase_04 AC 337 ms
35,476 KB
testcase_05 AC 257 ms
22,588 KB
testcase_06 AC 265 ms
26,320 KB
testcase_07 AC 354 ms
11,392 KB
testcase_08 AC 281 ms
14,224 KB
testcase_09 AC 647 ms
25,916 KB
testcase_10 AC 410 ms
17,528 KB
testcase_11 AC 642 ms
17,432 KB
testcase_12 AC 923 ms
35,172 KB
testcase_13 AC 988 ms
36,228 KB
testcase_14 AC 977 ms
36,228 KB
testcase_15 AC 923 ms
36,228 KB
testcase_16 AC 983 ms
36,228 KB
testcase_17 AC 971 ms
36,228 KB
testcase_18 AC 29 ms
9,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,Q = map(int, input().split())
A = list(map(int, input().split()))

B = sorted(A)
D = {B[i]:i for i in range(len(B))}
E = {B[i]:i for i in range(len(B)-1, -1, -1)}

for _ in range(Q):
    x,y = map(int, input().split())
    i = E[A[x-1]]
    j = D[A[y-1]]
    print(max(0, i-j-1))
0