Submission #66617149


Source Code Expand

import sys
import bisect

input = sys.stdin.read
data = input().splitlines()

Q = int(data[0])
cards = []
results = []

for i in range(1, Q + 1):
    line = data[i].split()
    t, x = int(line[0]), int(line[1])

    if t == 1:
        bisect.insort(cards, x)  # O(log N) 挿入
    elif t == 2:
        index = bisect.bisect_left(cards, x)
        if index < len(cards) and cards[index] == x:
            cards.pop(index)  # O(N) だが平均的には高速
    elif t == 3:
        index = bisect.bisect_left(cards, x)  # x 以上の最小の index
        if index < len(cards):
            results.append(str(cards[index]))
        else:
            results.append("-1")

print("\n".join(results))

Submission Info

Submission Time
Task A55 - Set
User myoshizumi
Language Python (CPython 3.11.4)
Score 1000
Code Size 729 Byte
Status AC
Exec Time 539 ms
Memory 19620 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 1000 / 1000
Status
AC × 1
AC × 7
Set Name Test Cases
Sample sample_01
All max_01, random_01, random_02, random_03, random_04, random_05, sample_01
Case Name Status Exec Time Memory
max_01 AC 539 ms 19620 KiB
random_01 AC 10 ms 8888 KiB
random_02 AC 10 ms 8828 KiB
random_03 AC 11 ms 8936 KiB
random_04 AC 20 ms 9760 KiB
random_05 AC 299 ms 18892 KiB
sample_01 AC 10 ms 8816 KiB