結果

問題 No.2961 Shiny Monster Master
コンテスト
ユーザー detteiuu
提出日時 2024-11-16 15:38:42
言語 PyPy3
(7.3.23 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 85 ms / 1,777 ms
+ 937µs
コード長 440 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 67 ms
コンパイル使用メモリ 81,348 KB
実行使用メモリ 99,384 KB
最終ジャッジ日時 2026-09-24 18:44:09
合計ジャッジ時間 9,248 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 77
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from bisect import bisect_left, bisect_right

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

for L, R in LR:
    if L//X == R//X:
        print(bisect_right(A, R%X)-bisect_left(A, L%X))
    else:
        ans = (N-bisect_left(A, L%X))+bisect_right(A, R%X)
        if R//X-L//X >= 2:
            ans += N*(R//X-L//X-1)
        print(ans)
0