Submission #69487296


Source Code Expand

from heapq import heapify, heappop, heappush


SIZE = 31


def solve(N, K, X, A):
    h = [(-float(a), 1) for a in A]
    heapify(h)

    while K:
        a, c = heappop(h)
        d = min(K, c)
        K -= d
        heappush(h, (a / 2, d * 2))
        if d != c:
            heappush(h, (a, c - d))

    for a, c in sorted(h):
        if X <= c:
            return -a
        X -= c


def main():
    T = int(input())
    for t in range(T):
        N, K, X = map(int, input().split())
        A = list(map(int, input().split()))
        ans = solve(N, K, X, A)
        print(ans)


main()

"""
とりあえず <<31したら整数で扱える

棒の最大値は二分探索で求められる→別にシミュレーションしてもいい…

棒の長さの種類はN+1しかないはず

"""

Submission Info

Submission Time
Task E - Cut in Half
User mo12412
Language Python (PyPy 3.10-v7.3.12)
Score 475
Code Size 840 Byte
Status AC
Exec Time 1141 ms
Memory 164152 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 475 / 475
Status
AC × 1
AC × 36
Set Name Test Cases
Sample sample_01.txt
All 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, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt, random_30.txt, random_31.txt, random_32.txt, random_33.txt, random_34.txt, random_35.txt, sample_01.txt
Case Name Status Exec Time Memory
random_01.txt AC 1113 ms 163572 KiB
random_02.txt AC 663 ms 132992 KiB
random_03.txt AC 1019 ms 155932 KiB
random_04.txt AC 719 ms 134432 KiB
random_05.txt AC 1141 ms 164152 KiB
random_06.txt AC 858 ms 147028 KiB
random_07.txt AC 1035 ms 156224 KiB
random_08.txt AC 897 ms 147680 KiB
random_09.txt AC 571 ms 93216 KiB
random_10.txt AC 575 ms 90068 KiB
random_11.txt AC 551 ms 92668 KiB
random_12.txt AC 533 ms 89472 KiB
random_13.txt AC 582 ms 93132 KiB
random_14.txt AC 573 ms 89700 KiB
random_15.txt AC 550 ms 92920 KiB
random_16.txt AC 533 ms 89816 KiB
random_17.txt AC 476 ms 151704 KiB
random_18.txt AC 489 ms 152380 KiB
random_19.txt AC 477 ms 152460 KiB
random_20.txt AC 479 ms 151548 KiB
random_21.txt AC 471 ms 152460 KiB
random_22.txt AC 467 ms 152708 KiB
random_23.txt AC 684 ms 148308 KiB
random_24.txt AC 695 ms 144904 KiB
random_25.txt AC 694 ms 147636 KiB
random_26.txt AC 700 ms 146948 KiB
random_27.txt AC 709 ms 147452 KiB
random_28.txt AC 650 ms 142904 KiB
random_29.txt AC 574 ms 150668 KiB
random_30.txt AC 567 ms 150296 KiB
random_31.txt AC 96 ms 103220 KiB
random_32.txt AC 60 ms 76688 KiB
random_33.txt AC 342 ms 86400 KiB
random_34.txt AC 350 ms 85968 KiB
random_35.txt AC 337 ms 85128 KiB
sample_01.txt AC 60 ms 76476 KiB