Submission #1091517

# Submission time Handle Problem Language Result Execution time Memory
1091517 2024-09-21T04:58:22 Z vjudge1 Potatoes and fertilizers (LMIO19_bulves) Python 3
24 / 100
1000 ms 53296 KB
n = int(input())

a = [0] * n
b = [0] * n

for i in range(n):
    x, y = map(int, input().split())
    a[i] = x
    b[i] = y

# subtask 1 only
ans = 0
extra = 0
suffix = []
for i in range(n):
    ans += abs(extra)
    extra += a[i] - b[i]
    suffix.append(-1 if extra > 0 else 1)

if sum(a) == sum(b) + 1:
    # subtask 2
    current = ans
    suffix.pop()
    total = 0
    while len(suffix) > 0:
        total += suffix.pop()
        ans = min(ans, current + total)

print(ans)
# Verdict Execution time Memory Grader output
1 Correct 11 ms 2908 KB Output is correct
2 Correct 15 ms 2908 KB Output is correct
3 Correct 16 ms 3064 KB Output is correct
4 Correct 91 ms 5928 KB Output is correct
5 Correct 174 ms 8784 KB Output is correct
6 Correct 432 ms 27992 KB Output is correct
7 Correct 841 ms 53296 KB Output is correct
8 Correct 839 ms 35412 KB Output is correct
9 Correct 886 ms 34904 KB Output is correct
10 Correct 759 ms 16600 KB Output is correct
11 Correct 777 ms 16548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 2908 KB Output is correct
2 Correct 15 ms 2908 KB Output is correct
3 Correct 16 ms 3064 KB Output is correct
4 Correct 91 ms 5928 KB Output is correct
5 Correct 174 ms 8784 KB Output is correct
6 Correct 432 ms 27992 KB Output is correct
7 Correct 841 ms 53296 KB Output is correct
8 Correct 839 ms 35412 KB Output is correct
9 Correct 886 ms 34904 KB Output is correct
10 Correct 759 ms 16600 KB Output is correct
11 Correct 777 ms 16548 KB Output is correct
12 Correct 264 ms 15552 KB Output is correct
13 Correct 606 ms 33080 KB Output is correct
14 Execution timed out 1038 ms 53248 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 11 ms 2908 KB Output is correct
2 Correct 15 ms 2908 KB Output is correct
3 Incorrect 12 ms 2908 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 11 ms 2908 KB Output is correct
2 Correct 15 ms 2908 KB Output is correct
3 Correct 16 ms 3064 KB Output is correct
4 Incorrect 12 ms 2908 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 11 ms 2908 KB Output is correct
2 Correct 15 ms 2908 KB Output is correct
3 Correct 16 ms 3064 KB Output is correct
4 Incorrect 12 ms 2908 KB Output isn't correct
5 Halted 0 ms 0 KB -