結果

問題 No.759 悪くない忘年会にしような!
ユーザー matsu7874matsu7874
提出日時 2018-12-06 02:37:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,069 ms / 2,000 ms
コード長 1,613 bytes
コンパイル時間 1,098 ms
コンパイル使用メモリ 86,904 KB
実行使用メモリ 108,476 KB
最終ジャッジ日時 2023-10-11 13:47:40
合計ジャッジ時間 28,545 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
75,832 KB
testcase_01 AC 76 ms
76,000 KB
testcase_02 AC 75 ms
75,484 KB
testcase_03 AC 74 ms
75,628 KB
testcase_04 AC 77 ms
75,484 KB
testcase_05 AC 76 ms
76,000 KB
testcase_06 AC 76 ms
75,772 KB
testcase_07 AC 76 ms
75,788 KB
testcase_08 AC 76 ms
75,996 KB
testcase_09 AC 77 ms
76,004 KB
testcase_10 AC 75 ms
75,996 KB
testcase_11 AC 77 ms
75,968 KB
testcase_12 AC 77 ms
75,848 KB
testcase_13 AC 76 ms
75,772 KB
testcase_14 AC 76 ms
75,488 KB
testcase_15 AC 75 ms
75,832 KB
testcase_16 AC 76 ms
75,848 KB
testcase_17 AC 77 ms
75,840 KB
testcase_18 AC 78 ms
75,692 KB
testcase_19 AC 78 ms
75,480 KB
testcase_20 AC 78 ms
75,760 KB
testcase_21 AC 82 ms
75,996 KB
testcase_22 AC 81 ms
75,828 KB
testcase_23 AC 80 ms
75,784 KB
testcase_24 AC 78 ms
75,692 KB
testcase_25 AC 78 ms
75,972 KB
testcase_26 AC 77 ms
75,616 KB
testcase_27 AC 77 ms
75,768 KB
testcase_28 AC 78 ms
75,800 KB
testcase_29 AC 78 ms
75,860 KB
testcase_30 AC 79 ms
75,624 KB
testcase_31 AC 78 ms
75,764 KB
testcase_32 AC 76 ms
75,768 KB
testcase_33 AC 237 ms
81,056 KB
testcase_34 AC 164 ms
80,060 KB
testcase_35 AC 196 ms
80,304 KB
testcase_36 AC 239 ms
81,644 KB
testcase_37 AC 144 ms
79,080 KB
testcase_38 AC 253 ms
81,812 KB
testcase_39 AC 160 ms
80,084 KB
testcase_40 AC 222 ms
81,328 KB
testcase_41 AC 221 ms
81,136 KB
testcase_42 AC 219 ms
80,872 KB
testcase_43 AC 249 ms
82,680 KB
testcase_44 AC 823 ms
100,000 KB
testcase_45 AC 904 ms
100,268 KB
testcase_46 AC 868 ms
100,304 KB
testcase_47 AC 887 ms
100,276 KB
testcase_48 AC 1,069 ms
101,784 KB
testcase_49 AC 209 ms
80,952 KB
testcase_50 AC 237 ms
81,668 KB
testcase_51 AC 277 ms
82,588 KB
testcase_52 AC 251 ms
82,836 KB
testcase_53 AC 937 ms
100,940 KB
testcase_54 AC 878 ms
100,992 KB
testcase_55 AC 906 ms
100,584 KB
testcase_56 AC 1,025 ms
101,388 KB
testcase_57 AC 1,043 ms
100,676 KB
testcase_58 AC 851 ms
100,760 KB
testcase_59 AC 1,014 ms
100,516 KB
testcase_60 AC 897 ms
101,240 KB
testcase_61 AC 875 ms
100,512 KB
testcase_62 AC 989 ms
101,128 KB
testcase_63 AC 941 ms
107,264 KB
testcase_64 AC 942 ms
108,476 KB
testcase_65 AC 929 ms
101,100 KB
testcase_66 AC 864 ms
106,716 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**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