結果
問題 | No.2359 A in S ? |
ユーザー | mkawa2 |
提出日時 | 2023-06-23 22:25:35 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,626 bytes |
コンパイル時間 | 283 ms |
コンパイル使用メモリ | 86,960 KB |
実行使用メモリ | 114,804 KB |
最終ジャッジ日時 | 2023-09-13 17:27:27 |
合計ジャッジ時間 | 15,930 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 92 ms
72,332 KB |
testcase_01 | AC | 92 ms
72,620 KB |
testcase_02 | AC | 113 ms
78,536 KB |
testcase_03 | AC | 91 ms
72,252 KB |
testcase_04 | AC | 407 ms
112,592 KB |
testcase_05 | AC | 1,263 ms
114,804 KB |
testcase_06 | AC | 641 ms
114,100 KB |
testcase_07 | AC | 303 ms
111,324 KB |
testcase_08 | TLE | - |
testcase_09 | AC | 255 ms
112,252 KB |
testcase_10 | AC | 1,705 ms
111,272 KB |
testcase_11 | AC | 1,657 ms
111,708 KB |
testcase_12 | AC | 417 ms
112,488 KB |
testcase_13 | AC | 430 ms
113,060 KB |
testcase_14 | AC | 676 ms
113,876 KB |
testcase_15 | AC | 262 ms
112,172 KB |
testcase_16 | AC | 840 ms
113,824 KB |
testcase_17 | AC | 763 ms
113,684 KB |
testcase_18 | AC | 765 ms
113,288 KB |
testcase_19 | AC | 799 ms
113,476 KB |
ソースコード
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")