結果

問題 No.759 悪くない忘年会にしような!
ユーザー matsu7874matsu7874
提出日時 2018-12-06 02:50:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,211 ms / 2,000 ms
コード長 1,675 bytes
コンパイル時間 1,295 ms
コンパイル使用メモリ 87,084 KB
実行使用メモリ 108,712 KB
最終ジャッジ日時 2023-10-11 14:10:51
合計ジャッジ時間 29,545 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
75,904 KB
testcase_01 AC 77 ms
75,940 KB
testcase_02 AC 78 ms
75,984 KB
testcase_03 AC 79 ms
76,096 KB
testcase_04 AC 79 ms
76,036 KB
testcase_05 AC 78 ms
76,136 KB
testcase_06 AC 77 ms
75,912 KB
testcase_07 AC 79 ms
76,076 KB
testcase_08 AC 77 ms
75,936 KB
testcase_09 AC 78 ms
75,808 KB
testcase_10 AC 77 ms
75,848 KB
testcase_11 AC 79 ms
76,124 KB
testcase_12 AC 78 ms
76,080 KB
testcase_13 AC 77 ms
76,024 KB
testcase_14 AC 78 ms
76,128 KB
testcase_15 AC 78 ms
76,072 KB
testcase_16 AC 79 ms
76,020 KB
testcase_17 AC 77 ms
75,980 KB
testcase_18 AC 78 ms
76,068 KB
testcase_19 AC 78 ms
76,112 KB
testcase_20 AC 78 ms
75,844 KB
testcase_21 AC 81 ms
76,100 KB
testcase_22 AC 79 ms
76,032 KB
testcase_23 AC 79 ms
76,024 KB
testcase_24 AC 77 ms
75,936 KB
testcase_25 AC 77 ms
76,216 KB
testcase_26 AC 79 ms
75,848 KB
testcase_27 AC 80 ms
76,020 KB
testcase_28 AC 81 ms
76,120 KB
testcase_29 AC 77 ms
75,808 KB
testcase_30 AC 77 ms
75,820 KB
testcase_31 AC 77 ms
76,048 KB
testcase_32 AC 78 ms
76,084 KB
testcase_33 AC 235 ms
81,376 KB
testcase_34 AC 163 ms
80,248 KB
testcase_35 AC 207 ms
80,724 KB
testcase_36 AC 245 ms
81,616 KB
testcase_37 AC 148 ms
79,444 KB
testcase_38 AC 257 ms
81,936 KB
testcase_39 AC 170 ms
80,284 KB
testcase_40 AC 216 ms
81,756 KB
testcase_41 AC 229 ms
81,512 KB
testcase_42 AC 225 ms
81,136 KB
testcase_43 AC 258 ms
83,184 KB
testcase_44 AC 937 ms
100,160 KB
testcase_45 AC 992 ms
100,320 KB
testcase_46 AC 993 ms
100,300 KB
testcase_47 AC 944 ms
100,632 KB
testcase_48 AC 1,211 ms
102,068 KB
testcase_49 AC 215 ms
81,280 KB
testcase_50 AC 243 ms
81,848 KB
testcase_51 AC 280 ms
82,852 KB
testcase_52 AC 255 ms
82,756 KB
testcase_53 AC 948 ms
101,492 KB
testcase_54 AC 924 ms
101,256 KB
testcase_55 AC 886 ms
100,972 KB
testcase_56 AC 1,080 ms
101,504 KB
testcase_57 AC 1,061 ms
100,760 KB
testcase_58 AC 871 ms
100,780 KB
testcase_59 AC 996 ms
100,680 KB
testcase_60 AC 889 ms
101,672 KB
testcase_61 AC 862 ms
100,348 KB
testcase_62 AC 929 ms
101,096 KB
testcase_63 AC 886 ms
108,076 KB
testcase_64 AC 981 ms
108,712 KB
testcase_65 AC 951 ms
101,248 KB
testcase_66 AC 964 ms
106,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

class SegmentTree():

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

    def update(self, target, new_value):
        target += self.size - 1
        self.st[target] = new_value
        while target > 0:
            parent = (target - 1) >> 1
            if self.st[parent] < self.st[target]:
                self.st[parent] = self.st[target]
                target = parent
            else:
                break

    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 << 1) + 1, l, (l + r) >> 1)
        vr = self._query(a, b, (k << 1) + 2, (l + r) >> 1, r)
        return max(vl, vr)


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

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

    v_max = 10**4
    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