結果
問題 | No.2961 Shiny Monster Master |
ユーザー |
|
提出日時 | 2024-11-16 17:05:53 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 706 bytes |
コンパイル時間 | 374 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 139,472 KB |
最終ジャッジ日時 | 2024-11-16 17:06:07 |
合計ジャッジ時間 | 13,015 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 54 WA * 23 |
ソースコード
R,N=map(int,input().split()) A=set(list(map(int,input().split()))) B=[0]*R for a in A: B[a]=1 A=B #print(A) Q=int(input()) from itertools import accumulate S=list(accumulate(A)) #あるリストAの累積和リスト #S[i]=A[0]+A[1]+...+A[i] def add(S,l,r):#累積和Sに対して a[l]+...+a[r] を返す(半開区間にしたほうがいいのか...?) if l==0: return S[r] else: return S[r]-S[l-1] #print(S) def f1(a,b):#a以下で最大のbの倍数 return (a//b)*b def g1(a,b): return ((a+b-1)//b)*b SA=sum(A) for i in range(Q): l,r=map(int,input().split()) g=g1(l,R) f=f1(r,R) if r<g: print(add(S,l%R,r%R)) else: print(add(S,l%R,R-2)+add(S,1,r%R)+SA*((f-g)//R))