Submission #1087518

# Submission time Handle Problem Language Result Execution time Memory
1087518 2024-09-12T20:12:03 Z YannickOfungi Archery (IOI09_archery) Python 3
0 / 100
19 ms 3692 KB
import sys
import threading

def main():
    import sys
    input = sys.stdin.readline

    N, R = map(int, sys.stdin.readline().split())
    R0 = int(sys.stdin.readline())  # Our rank
    other_ranks = []
    for _ in range(2*N - 1):
        other_ranks.append(int(sys.stdin.readline()))
    # Arrange other archers into targets
    better_archers_count_per_target = [0] * (N + 2)  # 1-indexed, up to N
    for t in range(1, N+1):
        idx1 = 2*(t-1)  # positions in other_ranks list (0-based)
        idx2 = 2*(t-1) + 1
        count = 0
        if idx1 < len(other_ranks) and other_ranks[idx1] < R0:
            count += 1
        if idx2 < len(other_ranks) and other_ranks[idx2] < R0:
            count += 1
        better_archers_count_per_target[t] = count
    # Compute suffix sums
    suffix_sum_better_archers = [0] * (N + 2)  # indices from 1 to N+1
    for t in range(N, 0, -1):
        suffix_sum_better_archers[t] = suffix_sum_better_archers[t+1] + better_archers_count_per_target[t]
    # Find the best starting target
    min_finishing_target = float('inf')
    best_t = -1
    for t in range(1, N+1):
        finishing_target = t + suffix_sum_better_archers[t+1]
        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 14 ms 3432 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 15 ms 3484 KB Execution failed because the return code was nonzero
5 Runtime error 14 ms 3468 KB Execution failed because the return code was nonzero
6 Runtime error 14 ms 3676 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 19 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 14 ms 3676 KB Execution failed because the return code was nonzero
5 Runtime error 15 ms 3692 KB Execution failed because the return code was nonzero
6 Runtime error 14 ms 3660 KB Execution failed because the return code was nonzero
7 Runtime error 15 ms 3676 KB Execution failed because the return code was nonzero
8 Runtime error 15 ms 3488 KB Execution failed because the return code was nonzero
9 Runtime error 14 ms 3668 KB Execution failed because the return code was nonzero
10 Runtime error 15 ms 3676 KB Execution failed because the return code was nonzero
11 Runtime error 15 ms 3468 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 15 ms 3676 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 15 ms 3676 KB Execution failed because the return code was nonzero
16 Runtime error 14 ms 3676 KB Execution failed because the return code was nonzero
17 Runtime error 15 ms 3676 KB Execution failed because the return code was nonzero
18 Runtime error 15 ms 3676 KB Execution failed because the return code was nonzero
19 Runtime error 14 ms 3676 KB Execution failed because the return code was nonzero
20 Runtime error 15 ms 3676 KB Execution failed because the return code was nonzero
21 Runtime error 16 ms 3480 KB Execution failed because the return code was nonzero
22 Runtime error 16 ms 3676 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 16 ms 3676 KB Execution failed because the return code was nonzero
25 Runtime error 15 ms 3648 KB Execution failed because the return code was nonzero
26 Runtime error 15 ms 3676 KB Execution failed because the return code was nonzero
27 Runtime error 14 ms 3636 KB Execution failed because the return code was nonzero
28 Runtime error 19 ms 3668 KB Execution failed because the return code was nonzero
29 Runtime error 17 ms 3676 KB Execution failed because the return code was nonzero
30 Runtime error 15 ms 3520 KB Execution failed because the return code was nonzero
31 Runtime error 15 ms 3676 KB Execution failed because the return code was nonzero
32 Runtime error 14 ms 3676 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 3496 KB Execution failed because the return code was nonzero
35 Runtime error 15 ms 3548 KB Execution failed because the return code was nonzero
36 Runtime error 14 ms 3524 KB Execution failed because the return code was nonzero
37 Runtime error 15 ms 3676 KB Execution failed because the return code was nonzero
38 Runtime error 15 ms 3680 KB Execution failed because the return code was nonzero
39 Runtime error 17 ms 3676 KB Execution failed because the return code was nonzero
40 Runtime error 15 ms 3684 KB Execution failed because the return code was nonzero
41 Runtime error 14 ms 3676 KB Execution failed because the return code was nonzero
42 Runtime error 15 ms 3680 KB Execution failed because the return code was nonzero
43 Runtime error 15 ms 3676 KB Execution failed because the return code was nonzero
44 Runtime error 16 ms 3596 KB Execution failed because the return code was nonzero
45 Runtime error 14 ms 3616 KB Execution failed because the return code was nonzero
46 Runtime error 15 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