結果
問題 | No.2359 A in S ? |
ユーザー |
![]() |
提出日時 | 2023-06-23 22:27:22 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,563 ms / 2,000 ms |
コード長 | 1,626 bytes |
コンパイル時間 | 148 ms |
コンパイル使用メモリ | 82,368 KB |
実行使用メモリ | 116,312 KB |
最終ジャッジ日時 | 2024-07-01 02:10:50 |
合計ジャッジ時間 | 13,855 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
ソースコード
import sys# sys.setrecursionlimit(200005)# sys.set_int_max_str_digits(1000005)int1 = lambda x: int(x)-1pDB = lambda *x: print(*x, end="\n", file=sys.stderr)p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)def II(): return int(sys.stdin.readline())def LI(): return list(map(int, sys.stdin.readline().split()))def LLI(rows_number): return [LI() for _ in range(rows_number)]def LI1(): return list(map(int1, sys.stdin.readline().split()))def LLI1(rows_number): return [LI1() for _ in range(rows_number)]def SI(): return sys.stdin.readline().rstrip()dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]inf = (1 << 63)-1md = 10**9+7# md = 998244353from heapq import *from collections import defaultdict, Countermx = 100000sq = 200n, m = LI()lrxy = LLI(n)aa = LI()ja = sorted(enumerate(aa), key=lambda x: x[1])lrxy.sort(key=lambda x: -x[0])ans = [0]*mxtoy = defaultdict(Counter)cnt = [0]*(mx+1)hp = []for j, a in ja:while lrxy and lrxy[-1][0] <= a:l, r, x, y = lrxy.pop()if x < sq:xtoy[x][y] += 1else:for i in range(y, mx+1, x): cnt[i] += 1heappush(hp, (r, x, y))while hp and hp[0][0] < a:r, x, y = heappop(hp)if x < sq:xtoy[x][y] -= 1if xtoy[x][y] == 0: del xtoy[x][y]if not xtoy[x]:del xtoy[x]else:for i in range(y, mx+1, x): cnt[i] -= 1ans[j] = cnt[a]for x in xtoy:b = a%xif b in xtoy[x]: ans[j] += xtoy[x][b]print(*ans,sep="\n")