結果

問題 No.759 悪くない忘年会にしような!
ユーザー matsu7874matsu7874
提出日時 2018-12-06 01:36:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,415 ms / 2,000 ms
コード長 1,613 bytes
コンパイル時間 284 ms
コンパイル使用メモリ 87,120 KB
実行使用メモリ 115,052 KB
最終ジャッジ日時 2023-10-11 13:14:37
合計ジャッジ時間 32,552 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
79,180 KB
testcase_01 AC 80 ms
79,040 KB
testcase_02 AC 81 ms
78,964 KB
testcase_03 AC 83 ms
78,820 KB
testcase_04 AC 82 ms
79,012 KB
testcase_05 AC 82 ms
78,820 KB
testcase_06 AC 82 ms
79,012 KB
testcase_07 AC 83 ms
79,280 KB
testcase_08 AC 82 ms
79,208 KB
testcase_09 AC 84 ms
79,316 KB
testcase_10 AC 84 ms
78,812 KB
testcase_11 AC 85 ms
79,180 KB
testcase_12 AC 85 ms
78,964 KB
testcase_13 AC 82 ms
79,060 KB
testcase_14 AC 83 ms
79,180 KB
testcase_15 AC 81 ms
79,124 KB
testcase_16 AC 83 ms
79,212 KB
testcase_17 AC 83 ms
79,196 KB
testcase_18 AC 82 ms
79,288 KB
testcase_19 AC 84 ms
79,148 KB
testcase_20 AC 84 ms
79,296 KB
testcase_21 AC 84 ms
79,256 KB
testcase_22 AC 83 ms
79,044 KB
testcase_23 AC 82 ms
79,120 KB
testcase_24 AC 83 ms
79,288 KB
testcase_25 AC 84 ms
79,316 KB
testcase_26 AC 82 ms
79,148 KB
testcase_27 AC 83 ms
79,260 KB
testcase_28 AC 85 ms
79,192 KB
testcase_29 AC 84 ms
79,252 KB
testcase_30 AC 85 ms
79,064 KB
testcase_31 AC 84 ms
79,016 KB
testcase_32 AC 84 ms
79,148 KB
testcase_33 AC 254 ms
87,224 KB
testcase_34 AC 172 ms
85,760 KB
testcase_35 AC 236 ms
87,160 KB
testcase_36 AC 211 ms
86,592 KB
testcase_37 AC 172 ms
86,224 KB
testcase_38 AC 228 ms
86,996 KB
testcase_39 AC 159 ms
85,476 KB
testcase_40 AC 215 ms
86,340 KB
testcase_41 AC 271 ms
88,360 KB
testcase_42 AC 261 ms
87,696 KB
testcase_43 AC 280 ms
87,936 KB
testcase_44 AC 1,072 ms
106,740 KB
testcase_45 AC 1,268 ms
108,720 KB
testcase_46 AC 1,154 ms
107,100 KB
testcase_47 AC 1,152 ms
106,512 KB
testcase_48 AC 1,142 ms
107,072 KB
testcase_49 AC 238 ms
87,096 KB
testcase_50 AC 233 ms
87,452 KB
testcase_51 AC 243 ms
88,620 KB
testcase_52 AC 311 ms
89,968 KB
testcase_53 AC 1,012 ms
106,536 KB
testcase_54 AC 1,049 ms
106,672 KB
testcase_55 AC 1,391 ms
108,132 KB
testcase_56 AC 1,415 ms
107,852 KB
testcase_57 AC 1,414 ms
108,456 KB
testcase_58 AC 1,149 ms
107,120 KB
testcase_59 AC 1,076 ms
106,412 KB
testcase_60 AC 1,062 ms
106,872 KB
testcase_61 AC 1,133 ms
108,088 KB
testcase_62 AC 1,096 ms
107,244 KB
testcase_63 AC 1,046 ms
115,052 KB
testcase_64 AC 1,078 ms
114,196 KB
testcase_65 AC 982 ms
106,020 KB
testcase_66 AC 1,047 ms
113,116 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

class SegmentTree():

    def __init__(self, size, initial=-1):
        node_size = 1
        while node_size < size:
            node_size <<= 1
        self.st = [initial] * (2 * node_size - 1)
        self.size = node_size

    def update(self, target, new_value):
        target += self.size - 1
        self.st[target] = new_value
        while target > 0:
            target = (target - 1) // 2
            self.st[target] = max(self.st[target * 2 + 1],
                                  self.st[target * 2 + 2])

    def query(self, a, b):
        # [a,b)の最大値を求める。
        return self._query(a, b, 0, 0, self.size)

    def _query(self, a, b, k, l, r):
        if r <= a or b <= l:
            return -1
        if a <= l and r <= b:
            return self.st[k]
        vl = self._query(a, b, k * 2 + 1, l, (l + r) // 2)
        vr = self._query(a, b, k * 2 + 2, (l + r) // 2, r)
        return max(vl, vr)


def main():
    n = int(input())

    points = [tuple(map(int, input().split())) for i in range(n)]

    v_max = 10**5
    partition_by_r = [[] for i in range(v_max + 1)]


    pt_max = SegmentTree(v_max + 1, -1)
    res = []

    for i, point in enumerate(points):
        p, t, r = point
        partition_by_r[r].append((p, t, i + 1))
    for ptis in partition_by_r[::-1]:
        ptis.sort(reverse=True)
        for pti in ptis:
            p, t, i = pti
            if t > pt_max.query(p, v_max + 1):
                res.append(i)
                pt_max.update(p, t)

    res.sort()
    for point_id in res:
        print(point_id)


if __name__ == '__main__':
    main()
0