Submission #1087514

# Submission time Handle Problem Language Result Execution time Memory
1087514 2024-09-12T19:54:28 Z Rainmaker2627 Archery (IOI09_archery) Python 3
0 / 100
20 ms 5484 KB
# Read input
import sys
import threading

def main():
    import sys

    sys.setrecursionlimit(1 << 25)
    N, R = map(int, sys.stdin.readline().split())
    R0 = int(sys.stdin.readline())
    positions = []
    for _ in range(2*N -1):
        positions.append(int(sys.stdin.readline()))

    better_archers_starting_positions = [0] * (2*N -1)
    for i in range(2*N -1):
        if positions[i] < R0:
            better_archers_starting_positions[i] = 1

    better_archers_starting_targets = [0] * N
    for t in range(N):
        pos1 = 2*t
        pos2 = 2*t +1
        if pos1 < 2*N -1:
            better_archers_starting_targets[t] += better_archers_starting_positions[pos1]
        if pos2 < 2*N -1:
            better_archers_starting_targets[t] += better_archers_starting_positions[pos2]

    suffix_sum_better = [0] * (N+1)
    for t in range(N-1, -1, -1):
        suffix_sum_better[t] = suffix_sum_better[t+1] + better_archers_starting_targets[t]

    min_finishing_target = float('inf')
    best_t = -1
    for t in range(1, N+1):
        N_better_right = suffix_sum_better[t]
        finishing_target = t + N_better_right
        if finishing_target < min_finishing_target:
            min_finishing_target = finishing_target
            best_t = t
        elif finishing_target == min_finishing_target and t > best_t:
            best_t = t

    print(best_t)

threading.Thread(target=main).start()
# Verdict Execution time Memory Grader output
1 Runtime error 15 ms 3676 KB Execution failed because the return code was nonzero
2 Runtime error 16 ms 3488 KB Execution failed because the return code was nonzero
3 Runtime error 14 ms 3676 KB Execution failed because the return code was nonzero
4 Runtime error 14 ms 3676 KB Execution failed because the return code was nonzero
5 Runtime error 14 ms 3676 KB Execution failed because the return code was nonzero
6 Runtime error 14 ms 3572 KB Execution failed because the return code was nonzero
# Verdict Execution time Memory Grader output
1 Runtime error 15 ms 3676 KB Execution failed because the return code was nonzero
2 Runtime error 15 ms 3448 KB Execution failed because the return code was nonzero
3 Runtime error 14 ms 3628 KB Execution failed because the return code was nonzero
4 Runtime error 15 ms 3676 KB Execution failed because the return code was nonzero
5 Runtime error 14 ms 3536 KB Execution failed because the return code was nonzero
6 Runtime error 15 ms 3676 KB Execution failed because the return code was nonzero
7 Runtime error 14 ms 3484 KB Execution failed because the return code was nonzero
8 Runtime error 14 ms 3532 KB Execution failed because the return code was nonzero
9 Runtime error 14 ms 3676 KB Execution failed because the return code was nonzero
10 Runtime error 14 ms 3456 KB Execution failed because the return code was nonzero
11 Runtime error 20 ms 3604 KB Execution failed because the return code was nonzero
12 Runtime error 15 ms 3676 KB Execution failed because the return code was nonzero
13 Runtime error 15 ms 3672 KB Execution failed because the return code was nonzero
14 Runtime error 15 ms 3676 KB Execution failed because the return code was nonzero
15 Runtime error 15 ms 3456 KB Execution failed because the return code was nonzero
16 Runtime error 15 ms 3584 KB Execution failed because the return code was nonzero
17 Runtime error 16 ms 3540 KB Execution failed because the return code was nonzero
18 Runtime error 15 ms 5484 KB Execution failed because the return code was nonzero
19 Runtime error 15 ms 3676 KB Execution failed because the return code was nonzero
20 Runtime error 14 ms 3676 KB Execution failed because the return code was nonzero
21 Runtime error 14 ms 3544 KB Execution failed because the return code was nonzero
22 Runtime error 15 ms 3672 KB Execution failed because the return code was nonzero
23 Runtime error 14 ms 3676 KB Execution failed because the return code was nonzero
24 Runtime error 14 ms 3536 KB Execution failed because the return code was nonzero
25 Runtime error 15 ms 3676 KB Execution failed because the return code was nonzero
26 Runtime error 14 ms 3568 KB Execution failed because the return code was nonzero
27 Runtime error 14 ms 3676 KB Execution failed because the return code was nonzero
28 Runtime error 14 ms 3584 KB Execution failed because the return code was nonzero
29 Runtime error 15 ms 3680 KB Execution failed because the return code was nonzero
30 Runtime error 15 ms 3676 KB Execution failed because the return code was nonzero
31 Runtime error 16 ms 3536 KB Execution failed because the return code was nonzero
32 Runtime error 14 ms 3672 KB Execution failed because the return code was nonzero
33 Runtime error 14 ms 3676 KB Execution failed because the return code was nonzero
34 Runtime error 15 ms 3488 KB Execution failed because the return code was nonzero
35 Runtime error 14 ms 3676 KB Execution failed because the return code was nonzero
36 Runtime error 14 ms 3688 KB Execution failed because the return code was nonzero
37 Runtime error 17 ms 3704 KB Execution failed because the return code was nonzero
38 Runtime error 15 ms 3676 KB Execution failed because the return code was nonzero
39 Runtime error 14 ms 3676 KB Execution failed because the return code was nonzero
40 Runtime error 14 ms 3684 KB Execution failed because the return code was nonzero
41 Runtime error 14 ms 3472 KB Execution failed because the return code was nonzero
42 Runtime error 14 ms 3696 KB Execution failed because the return code was nonzero
43 Runtime error 15 ms 3532 KB Execution failed because the return code was nonzero
44 Runtime error 17 ms 3680 KB Execution failed because the return code was nonzero
45 Runtime error 15 ms 3680 KB Execution failed because the return code was nonzero
46 Runtime error 14 ms 3468 KB Execution failed because the return code was nonzero
47 Runtime error 14 ms 3468 KB Execution failed because the return code was nonzero