結果

問題 No.2710 How many more?
ユーザー けん
提出日時 2024-11-01 22:03:02
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 618 bytes
コンパイル時間 503 ms
コンパイル使用メモリ 82,376 KB
実行使用メモリ 136,068 KB
最終ジャッジ日時 2024-11-01 22:03:12
合計ジャッジ時間 8,240 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 5 WA * 1 RE * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**8)

from collections import defaultdict

N, Q = map(int, input().split())
A = list(map(int, input().split()))
querys = [list(map(int, input().split())) for _ in range(Q)]

info = []

for i in range(N):
    info.append([A[i], i + 1])

allA = sorted(list(set(A)))

cnt = defaultdict(int)

for a in A:
    cnt[a] += 1

s = [0]

for a in allA:
    s.append(s[-1] + cnt[a])

place = defaultdict(int)

info.sort()

for n, e in enumerate(info):
    place[e[-1]] = n + 1

for x, y in querys:
    p1, p2 = place[x], place[y] 
    print(max(0, s[p1 - 1] - s[p2]))
0