結果
問題 |
No.2710 How many more?
|
ユーザー |
![]() |
提出日時 | 2024-03-31 15:46:00 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 585 ms / 2,000 ms |
コード長 | 479 bytes |
コンパイル時間 | 266 ms |
コンパイル使用メモリ | 82,468 KB |
実行使用メモリ | 108,968 KB |
最終ジャッジ日時 | 2024-09-30 20:55:25 |
合計ジャッジ時間 | 8,536 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 17 |
ソースコード
import sys input = sys.stdin.readline N,Q = map(int,input().split()) A = list(map(int,input().split())) XY = [tuple(map(int,input().split())) for _ in range(Q)] from collections import Counter C = Counter(A) sc = sorted(C.items()) cums = [0] ks = [] for k,v in sc: cums.append(cums[-1] + v) ks.append(k) from bisect import bisect for x,y in XY: x,y = x-1,y-1 a = A[x] b = A[y] i = bisect(ks,a)-1 j = bisect(ks,b) print(max(0, cums[i] - cums[j]))