結果
| 問題 |
No.2961 Shiny Monster Master
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-11-18 02:44:36 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 172 ms / 1,777 ms |
| コード長 | 568 bytes |
| コンパイル時間 | 489 ms |
| コンパイル使用メモリ | 82,372 KB |
| 実行使用メモリ | 142,028 KB |
| 最終ジャッジ日時 | 2024-11-18 02:44:49 |
| 合計ジャッジ時間 | 11,988 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 77 |
ソースコード
R,N=map(int,input().split())
A=sorted(list(map(int,input().split())))
B=[0]*R #カウンターがiのときチャンスがあるなら1、でなければ0
for a in A:
B[a]=1
Q=int(input())
from itertools import accumulate
S=list(accumulate(B))
def add(S,l,r):#累積和Sに対して a[l]+...+a[r] を返す
if l==0:
return S[r]
else:
return S[r]-S[l-1]
for i in range(Q):
l,r=map(int,input().split())
if l//R==r//R:#もしlとrが同一区間におさまるなら
print(add(S,l%R,r%R))
else:
print(add(S,l%R,R-1)+add(S,0,r%R)+N*(r//R-l//R-1))