提出 #73540386
ソースコード 拡げる
# https://ikatakos.com/pot/programming_algorithm/data_structure/binary_indexed_tree
class Bit:
def __init__(self, n):
self.size = n
self.tree = [0] * (n + 1)
def sum(self, i):
s = 0
while i > 0:
if s < self.tree[i]:
s = self.tree[i]
i -= i & -i
return s
def add(self, i, x):
while i <= self.size:
if self.tree[i] < x:
self.tree[i] = x
i += i & -i
def solve(N,XYZ):
XYZ.sort(key=lambda x: (-x[0],-x[1],-x[2]))
MY = max(y for _, y, _ in XYZ)
bit = Bit(MY)
ans = 0
i = 0
while i < N:
j = i
A = []
x = XYZ[i][0]
while j < N and XYZ[j][0] == x:
A.append(XYZ[j])
j += 1
for _,y,z in A:
B = MY - y + 1
if bit.sum(B-1) <= z:
ans += 1
P = {}
for _,y,z in A:
if y not in P or P[y] < z:
P[y] = z
for y,z in P.items():
C = MY - y + 1
bit.add(C,z)
i = j
return ans
for _ in range(int(input())):
N = int(input())
XYZ = [list(map(int,input().split())) for _ in range(N)]
print(solve(N,XYZ))
提出情報
| 提出日時 | |
|---|---|
| 問題 | C - Strong Surname |
| ユーザ | glaceon1020 |
| 言語 | Python (PyPy 3.11-v7.3.20) |
| 得点 | 0 |
| コード長 | 1295 Byte |
| 結果 | WA |
| 実行時間 | 758 ms |
| メモリ | 139404 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||||
|---|---|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 0 / 600 | ||||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | 00_sample_01.txt |
| All | 00_sample_01.txt, hand-12.txt, hand-13.txt, hand-14.txt, hand-15.txt, hand-16.txt, hand-17.txt, hand-18.txt, hand-19.txt, hand-20.txt, hand-21.txt, hand-22.txt, random-01.txt, random-02.txt, random-03.txt, random-04.txt, random-05.txt, random-06.txt, random-07.txt, random-08.txt, random-09.txt, random-10.txt, random-11.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 00_sample_01.txt | AC | 53 ms | 80240 KiB |
| hand-12.txt | WA | 476 ms | 110352 KiB |
| hand-13.txt | WA | 601 ms | 133316 KiB |
| hand-14.txt | WA | 727 ms | 132912 KiB |
| hand-15.txt | WA | 719 ms | 133060 KiB |
| hand-16.txt | WA | 725 ms | 133092 KiB |
| hand-17.txt | WA | 573 ms | 131104 KiB |
| hand-18.txt | WA | 576 ms | 130936 KiB |
| hand-19.txt | AC | 641 ms | 139404 KiB |
| hand-20.txt | WA | 589 ms | 131008 KiB |
| hand-21.txt | WA | 580 ms | 131140 KiB |
| hand-22.txt | AC | 345 ms | 132472 KiB |
| random-01.txt | AC | 650 ms | 110920 KiB |
| random-02.txt | WA | 506 ms | 111796 KiB |
| random-03.txt | WA | 520 ms | 115324 KiB |
| random-04.txt | WA | 616 ms | 132128 KiB |
| random-05.txt | WA | 654 ms | 132544 KiB |
| random-06.txt | WA | 696 ms | 133120 KiB |
| random-07.txt | WA | 747 ms | 132968 KiB |
| random-08.txt | WA | 758 ms | 132996 KiB |
| random-09.txt | WA | 750 ms | 133048 KiB |
| random-10.txt | WA | 741 ms | 132580 KiB |
| random-11.txt | WA | 738 ms | 132844 KiB |