結果

問題 No.2710 How many more?
ユーザー prd_xxxprd_xxx
提出日時 2024-03-31 15:46:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 607 ms / 2,000 ms
コード長 479 bytes
コンパイル時間 245 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 108,420 KB
最終ジャッジ日時 2024-03-31 15:46:09
合計ジャッジ時間 8,669 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
55,608 KB
testcase_01 AC 42 ms
55,608 KB
testcase_02 AC 433 ms
98,036 KB
testcase_03 AC 393 ms
95,332 KB
testcase_04 AC 421 ms
99,772 KB
testcase_05 AC 283 ms
88,844 KB
testcase_06 AC 375 ms
96,156 KB
testcase_07 AC 227 ms
82,208 KB
testcase_08 AC 213 ms
83,580 KB
testcase_09 AC 447 ms
100,000 KB
testcase_10 AC 291 ms
89,140 KB
testcase_11 AC 322 ms
89,228 KB
testcase_12 AC 553 ms
104,424 KB
testcase_13 AC 571 ms
107,908 KB
testcase_14 AC 607 ms
107,780 KB
testcase_15 AC 601 ms
108,164 KB
testcase_16 AC 603 ms
107,780 KB
testcase_17 AC 584 ms
108,420 KB
testcase_18 AC 41 ms
55,608 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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]))
0