結果
問題 | No.2643 Many Range Sums Problems |
ユーザー | chineristAC |
提出日時 | 2024-02-19 22:37:10 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,118 bytes |
コンパイル時間 | 405 ms |
コンパイル使用メモリ | 81,700 KB |
実行使用メモリ | 86,820 KB |
最終ジャッジ日時 | 2024-02-19 22:37:26 |
合計ジャッジ時間 | 15,421 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
56,248 KB |
testcase_01 | AC | 38 ms
56,248 KB |
testcase_02 | AC | 41 ms
58,340 KB |
testcase_03 | AC | 537 ms
83,488 KB |
testcase_04 | AC | 454 ms
81,592 KB |
testcase_05 | AC | 435 ms
81,340 KB |
testcase_06 | AC | 632 ms
85,144 KB |
testcase_07 | AC | 578 ms
85,144 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | AC | 555 ms
83,740 KB |
testcase_11 | AC | 439 ms
81,464 KB |
testcase_12 | AC | 892 ms
84,900 KB |
testcase_13 | AC | 473 ms
86,820 KB |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | AC | 491 ms
83,268 KB |
testcase_18 | AC | 226 ms
79,140 KB |
testcase_19 | AC | 88 ms
77,220 KB |
testcase_20 | WA | - |
testcase_21 | AC | 93 ms
77,216 KB |
testcase_22 | AC | 232 ms
78,396 KB |
testcase_23 | AC | 345 ms
79,620 KB |
testcase_24 | AC | 569 ms
83,108 KB |
testcase_25 | AC | 542 ms
81,956 KB |
testcase_26 | AC | 131 ms
77,772 KB |
testcase_27 | AC | 137 ms
77,772 KB |
testcase_28 | AC | 39 ms
56,248 KB |
testcase_29 | AC | 38 ms
56,248 KB |
testcase_30 | AC | 600 ms
84,892 KB |
testcase_31 | WA | - |
testcase_32 | AC | 900 ms
84,260 KB |
testcase_33 | AC | 918 ms
84,772 KB |
ソースコード
import sys from itertools import permutations from heapq import heappop,heappush from collections import deque import random import bisect input = lambda :sys.stdin.readline().rstrip() mi = lambda :map(int,input().split()) li = lambda :list(mi()) class UnionFindVerSize(): def __init__(self, N): self._parent = [n for n in range(0, N)] self._size = [1] * N self.group = N def find_root(self, x): if self._parent[x] == x: return x self._parent[x] = self.find_root(self._parent[x]) return self._parent[x] def unite(self, x, y): gx = self.find_root(x) gy = self.find_root(y) if gx == gy: return self.group -= 1 if self._size[gx] < self._size[gy]: self._parent[gx] = gy self._size[gy] += self._size[gx] else: self._parent[gy] = gx self._size[gx] += self._size[gy] def get_size(self, x): return self._size[self.find_root(x)] def is_same_group(self, x, y): return self.find_root(x) == self.find_root(y) N,K = mi() cond = [] for _ in range(N): r,x = mi() cond.append((r,x)) res = [] for i in range(N): tmp = [(0,0)] * (N+1) for j in range(N)[::-1]: if j!=i: r,x = cond[j] """ A_j + tmp[j+1] - tmp[r] = X[j] """ a,b = -(tmp[j+1][0] - tmp[r][0]),x-(tmp[j+1][1] - tmp[r][1]) tmp[j] = (tmp[j+1][0]+a,tmp[j+1][1]+b) else: tmp[j] = (tmp[j+1][0]+1,tmp[j+1][1]) #print(tmp) l,r = 0,K for j in range(N): a,b = tmp[j][0]-tmp[j+1][0],tmp[j][1]-tmp[j+1][1] #print(a,b) if a == 0: if not 0 <= b <= K: res.append("No") break elif 0 < a: l = max(l,(-b+a-1)//a) r = min(r,(K-b)//a) else: r = max(r,(b)//(-a)) l = min(l,(-K+b+(-a)-1)//(-a)) else: #print("lr",l,r) res.append("Yes" if l <= r else "No") print(*res,sep="\n")