結果
| 問題 |
No.2961 Shiny Monster Master
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-06-18 22:04:04 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 159 ms / 1,777 ms |
| コード長 | 409 bytes |
| コンパイル時間 | 416 ms |
| コンパイル使用メモリ | 82,048 KB |
| 実行使用メモリ | 90,624 KB |
| 最終ジャッジ日時 | 2024-11-16 15:01:01 |
| 合計ジャッジ時間 | 10,592 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 77 |
ソースコード
import bisect
R,N=list(map(int,input().split()))
A=list(map(int,input().split()))
A=sorted(A)
Q=int(input())
for i in range(Q):
l,r=list(map(int,input().split()))
if l//R==r//R:
cl=bisect.bisect_left(A,l%R)
cr=bisect.bisect_right(A,r%R)
print(cr-cl)
else:
ans=((r//R)-(l//R)-1)*N
cl=bisect.bisect_left(A,l%R)
cr=bisect.bisect_right(A,r%R)
ans=ans+cr+(N-cl)
print(ans)