結果

問題 No.2710 How many more?
ユーザー noriocnorioc
提出日時 2024-04-02 01:11:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 483 ms / 2,000 ms
コード長 455 bytes
コンパイル時間 405 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 107,772 KB
最終ジャッジ日時 2024-04-02 01:11:24
合計ジャッジ時間 8,787 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 35 ms
53,460 KB
testcase_02 AC 423 ms
94,300 KB
testcase_03 AC 289 ms
94,584 KB
testcase_04 AC 237 ms
107,284 KB
testcase_05 AC 238 ms
89,872 KB
testcase_06 AC 219 ms
100,500 KB
testcase_07 AC 234 ms
77,528 KB
testcase_08 AC 205 ms
80,552 KB
testcase_09 AC 367 ms
100,332 KB
testcase_10 AC 255 ms
87,036 KB
testcase_11 AC 355 ms
83,812 KB
testcase_12 AC 454 ms
103,932 KB
testcase_13 AC 475 ms
107,772 KB
testcase_14 AC 471 ms
107,644 KB
testcase_15 AC 483 ms
107,644 KB
testcase_16 AC 467 ms
107,644 KB
testcase_17 AC 467 ms
107,644 KB
testcase_18 AC 36 ms
53,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_left, bisect_right

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

d = {}
for i, a in enumerate(A):
    d[i] = a

ss = sorted(A)
for _ in range(Q):
    x, y = map(lambda x: int(x)-1, input().split())
    # x が y に追いつくには
    if d[x] <= d[y]:
        print(0)
        continue

    # d[y] < s < d[x] の個数
    p = bisect_left(ss, d[y]+1)
    q = bisect_right(ss, d[x]-1)
    print(q - p)
0