結果

問題 No.2961 Shiny Monster Master
コンテスト
ユーザー miya145592
提出日時 2024-11-16 15:46:12
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 83 ms / 1,777 ms
コード長 405 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 204 ms
コンパイル使用メモリ 85,504 KB
実行使用メモリ 174,976 KB
最終ジャッジ日時 2026-05-11 21:02:33
合計ジャッジ時間 6,326 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 77
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
input = sys.stdin.readline
R, N = map(int, input().split())
A = list(map(int, input().split()))
Q = int(input())
LR = [list(map(int, input().split())) for _ in range(Q)]
cnt = [0 for _ in range(R)]
for a in A:
    cnt[a] += 1
S = [0]
for c in cnt:
    S.append(S[-1]+c)
for l, r in LR:
    rcnt = ((r+1)//R)*S[-1] + S[(r+1)%R]
    lcnt = (l//R)*S[-1] + S[l%R]
    ans = rcnt-lcnt
    print(ans)
0