結果
問題 |
No.885 アマリクエリ
|
ユーザー |
![]() |
提出日時 | 2025-03-06 21:42:59 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 355 ms / 2,000 ms |
コード長 | 469 bytes |
コンパイル時間 | 436 ms |
コンパイル使用メモリ | 82,796 KB |
実行使用メモリ | 105,404 KB |
最終ジャッジ日時 | 2025-03-06 21:43:04 |
合計ジャッジ時間 | 5,097 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
n=int(input()) a=list(map(int,input().split())) Q=int(input()) x=list(map(int,input().split()))+[0] s=[] for i in range(Q+1): if i==0 or x[s[-1]]>x[i]: s+=[i] g=[0]*(Q+1) for v in a: now=0 while now<Q: ok=len(s)-1 ng=-1 while ok-ng>1: m=(ok+ng)//2 if x[s[m]]<=v: ok=m else: ng=m g[now]+=v g[s[ok]]-=v now=s[ok] if now<Q: v%=x[now] for i in range(1,Q+1): g[i]+=g[i-1] print(*g[:Q],sep="\n")