답안 #1087515

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1087515 2024-09-12T19:55:07 Z YannickOfungi Archery (IOI09_archery) Python 3
0 / 100
19 ms 3688 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()
# 결과 실행 시간 메모리 Grader output
1 Runtime error 15 ms 3676 KB Execution failed because the return code was nonzero
2 Runtime error 15 ms 3676 KB Execution failed because the return code was nonzero
3 Runtime error 15 ms 3676 KB Execution failed because the return code was nonzero
4 Runtime error 16 ms 3688 KB Execution failed because the return code was nonzero
5 Runtime error 15 ms 3676 KB Execution failed because the return code was nonzero
6 Runtime error 14 ms 3676 KB Execution failed because the return code was nonzero
# 결과 실행 시간 메모리 Grader output
1 Runtime error 15 ms 3676 KB Execution failed because the return code was nonzero
2 Runtime error 15 ms 3444 KB Execution failed because the return code was nonzero
3 Runtime error 15 ms 3492 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 15 ms 3676 KB Execution failed because the return code was nonzero
6 Runtime error 14 ms 3676 KB Execution failed because the return code was nonzero
7 Runtime error 14 ms 3512 KB Execution failed because the return code was nonzero
8 Runtime error 14 ms 3676 KB Execution failed because the return code was nonzero
9 Runtime error 14 ms 3540 KB Execution failed because the return code was nonzero
10 Runtime error 14 ms 3672 KB Execution failed because the return code was nonzero
11 Runtime error 15 ms 3676 KB Execution failed because the return code was nonzero
12 Runtime error 14 ms 3676 KB Execution failed because the return code was nonzero
13 Runtime error 14 ms 3632 KB Execution failed because the return code was nonzero
14 Runtime error 14 ms 3676 KB Execution failed because the return code was nonzero
15 Runtime error 14 ms 3500 KB Execution failed because the return code was nonzero
16 Runtime error 16 ms 3676 KB Execution failed because the return code was nonzero
17 Runtime error 14 ms 3684 KB Execution failed because the return code was nonzero
18 Runtime error 14 ms 3576 KB Execution failed because the return code was nonzero
19 Runtime error 15 ms 3672 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 3676 KB Execution failed because the return code was nonzero
22 Runtime error 15 ms 3512 KB Execution failed because the return code was nonzero
23 Runtime error 15 ms 3676 KB Execution failed because the return code was nonzero
24 Runtime error 15 ms 3676 KB Execution failed because the return code was nonzero
25 Runtime error 15 ms 3688 KB Execution failed because the return code was nonzero
26 Runtime error 14 ms 3684 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 15 ms 3676 KB Execution failed because the return code was nonzero
29 Runtime error 19 ms 3492 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 3516 KB Execution failed because the return code was nonzero
32 Runtime error 18 ms 3676 KB Execution failed because the return code was nonzero
33 Runtime error 15 ms 3676 KB Execution failed because the return code was nonzero
34 Runtime error 15 ms 3500 KB Execution failed because the return code was nonzero
35 Runtime error 15 ms 3676 KB Execution failed because the return code was nonzero
36 Runtime error 15 ms 3652 KB Execution failed because the return code was nonzero
37 Runtime error 15 ms 3464 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 15 ms 3676 KB Execution failed because the return code was nonzero
40 Runtime error 16 ms 3544 KB Execution failed because the return code was nonzero
41 Runtime error 14 ms 3640 KB Execution failed because the return code was nonzero
42 Runtime error 15 ms 3676 KB Execution failed because the return code was nonzero
43 Runtime error 17 ms 3676 KB Execution failed because the return code was nonzero
44 Runtime error 15 ms 3676 KB Execution failed because the return code was nonzero
45 Runtime error 14 ms 3448 KB Execution failed because the return code was nonzero
46 Runtime error 16 ms 3676 KB Execution failed because the return code was nonzero
47 Runtime error 14 ms 3676 KB Execution failed because the return code was nonzero