結果
| 問題 |
No.2359 A in S ?
|
| コンテスト | |
| ユーザー |
mkawa2
|
| 提出日時 | 2023-06-23 22:25:35 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,626 bytes |
| コンパイル時間 | 142 ms |
| コンパイル使用メモリ | 81,892 KB |
| 実行使用メモリ | 116,280 KB |
| 最終ジャッジ日時 | 2024-07-01 02:09:17 |
| 合計ジャッジ時間 | 15,757 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 17 TLE * 1 |
ソースコード
import sys
# sys.setrecursionlimit(200005)
# sys.set_int_max_str_digits(1000005)
int1 = lambda x: int(x)-1
pDB = 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)-1
md = 10**9+7
# md = 998244353
from heapq import *
from collections import defaultdict, Counter
mx = 100000
sq = 316
n, 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]*m
xtoy = 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] += 1
else:
for i in range(y, mx+1, x): cnt[i] += 1
heappush(hp, (r, x, y))
while hp and hp[0][0] < a:
r, x, y = heappop(hp)
if x < sq:
xtoy[x][y] -= 1
if 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] -= 1
ans[j] = cnt[a]
for x in xtoy:
b = a%x
if b in xtoy[x]: ans[j] += xtoy[x][b]
print(*ans,sep="\n")
mkawa2