Submission details
Task:Roller coaster
Sender:aalto26hw_001
Submission time:2026-10-28 17:39:53 +0200
Language:Python3 (PyPy3)
Status:READY
Result:
Test results
testverdicttime
#10.04 sdetails
#20.04 sdetails
#30.04 sdetails
#40.04 sdetails
#50.04 sdetails
#60.04 sdetails
#70.04 sdetails
#80.04 sdetails
#90.04 sdetails
#100.04 sdetails
#110.04 sdetails
#120.04 sdetails

Code

# pyright: basic
import math

def test(min_speed):
    found = False
    num_happy = 0
    speed = min_speed
    too_slow = False
    for i in range(n):
        P = rc[i][0]
        R = rc[i][1]
        A = rc[i][2]
        F = rc[i][3]

        if speed < R:
            too_slow = True
            break
        if speed >= P:
            num_happy += 1
        speed = speed - A - math.ceil((speed * F) / 100)

    if too_slow or num_happy < n/2:
        min_speed = min_speed*2
    else:
        found = True
    return found


def binary_search(high, low):
    while low <= high:
        print("low: ", low, "high: ", high)
        mid = low + (high - low) // 2
        passed = test(mid)

        if passed:
            high = mid - 1
        else:
            low = mid + 1

    return mid

n = int(input())
rc = []

for i in range(n):
    x = input().split()
    y = (int(x[0]), int(x[1]), int(x[2]), int(x[3]))
    rc.append(y)

min_speed = 1

found = False
while not found:
    num_happy = 0
    speed = min_speed
    too_slow = False
    for i in range(n):
        P = rc[i][0]
        R = rc[i][1]
        A = rc[i][2]
        F = rc[i][3]

        if speed < R:
            too_slow = True
            break
        if speed >= P:
            num_happy += 1
        speed = speed - A - math.ceil((speed * F) / 100)

    if too_slow or num_happy < n/2:
        min_speed = min_speed*2
    else:
        found = True

min_speed = binary_search(min_speed, int(min_speed / 2))

print(min_speed)

Test details

Test 1

Verdict:

input
3
1000 5 5 0
20 20 20 50
50 50 0 99

correct output
145

user output
low:  128 high:  256
low:  128 high:  191
low:  128 high:  158
low:  144 high:  158
low:  144 high:  150
...

Feedback: Output is longer than expected

Test 2

Verdict:

input
10
1000000 1000000 1000000 99
1000000 1000000 1000000 99
1000000 1000000 1000000 99
1000000 1000000 1000000 99
...

correct output
2010101010101010100000000

user output
low:  120892581961462917470617...

Feedback: Output is longer than expected

Test 3

Verdict:

input
7
794772 933488 441001 5
271493 536110 509532 51
962838 821872 870163 38
499748 375441 611720 27
...

correct output
19316405

user output
low:  16777216 high:  33554432
low:  16777216 high:  25165823
low:  16777216 high:  20971518
low:  18874368 high:  20971518
low:  18874368 high:  19922942
...

Feedback: Output is longer than expected

Test 4

Verdict:

input
3
596853 888598 841235 97
66172 267459 123646 63
797926 471325 495185 83

correct output
81642158

user output
low:  67108864 high:  13421772...

Feedback: Output is longer than expected

Test 5

Verdict:

input
1
96033 88994 378596 21

correct output
96033

user output
low:  65536 high:  131072
low:  65536 high:  98303
low:  81920 high:  98303
low:  90112 high:  98303
low:  94208 high:  98303
...

Feedback: Output is longer than expected

Test 6

Verdict:

input
4
621429 570665 136758 47
960437 633256 497081 80
609067 68711 635017 1
952965 878149 492025 33

correct output
19366822

user output
low:  16777216 high:  33554432
low:  16777216 high:  25165823
low:  16777216 high:  20971518
low:  18874368 high:  20971518
low:  18874368 high:  19922942
...

Feedback: Output is longer than expected

Test 7

Verdict:

input
4
318031 108177 756250 50
502140 162500 94476 8
20779 421098 576089 37
839335 802331 61705 28

correct output
6474336

user output
low:  4194304 high:  8388608
low:  6291457 high:  8388608
low:  6291457 high:  7340031
low:  6291457 high:  6815743
low:  6291457 high:  6553599
...

Feedback: Output is longer than expected

Test 8

Verdict:

input
10
267853 777820 375951 88
988230 882388 775839 83
967127 555787 30414 59
813651 989181 261150 83
...

correct output
114240784216

user output
low:  68719476736 high:  13743...

Feedback: Output is longer than expected

Test 9

Verdict:

input
10
861881 84483 508595 97
274330 38611 473 18
695015 614973 493097 97
770531 391287 334900 98
...

correct output
26667465547194

user output
low:  17592186044416 high:  35...

Feedback: Output is longer than expected

Test 10

Verdict:

input
6
993908 158176 414002 83
50631 75954 861168 68
98702 383452 611097 7
953893 532084 225127 4
...

correct output
46921821

user output
low:  33554432 high:  67108864
low:  33554432 high:  50331647
low:  41943040 high:  50331647
low:  46137344 high:  50331647
low:  46137344 high:  48234494
...

Feedback: Output is longer than expected

Test 11

Verdict:

input
4
388404 393603 132467 24
739054 45905 89323 17
259460 850672 530957 26
420175 673047 31765 58

correct output
2895218

user output
low:  2097152 high:  4194304
low:  2097152 high:  3145727
low:  2621440 high:  3145727
low:  2883584 high:  3145727
low:  2883584 high:  3014654
...

Feedback: Output is longer than expected

Test 12

Verdict:

input
8
643002 391445 280110 17
195187 908655 709512 0
354760 527205 486247 77
84740 350249 581194 78
...

correct output
250399569

user output
low:  134217728 high:  2684354...

Feedback: Output is longer than expected