結果

問題 No.2961 Shiny Monster Master
ユーザー Meso Meso
提出日時 2024-11-16 19:26:37
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 100 ms / 1,777 ms
コード長 494 bytes
コンパイル時間 339 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 21,044 KB
最終ジャッジ日時 2024-11-16 19:26:45
合計ジャッジ時間 7,568 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 77
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect

R, N = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
q = int(input())

for i in range(q):
    l, r = map(int, input().split())
    if l // R == r // R:
        cntl = bisect.bisect_left(A, l%R)
        cntr = bisect.bisect_right(A, r%R)
        print(cntr - cntl)
    else:
        ans = ((r // R) - (l // R) - 1) * N
        cntl = bisect.bisect_left(A, l%R)
        cntr = bisect.bisect_right(A, r%R)
        ans += cntr + (N - cntl)
        print(ans)
0