Submission #217049

# Submission time Handle Problem Language Result Execution time Memory
217049 2020-03-28T18:34:20 Z sevlll Strange Device (APIO19_strange_device) PyPy
0 / 100
30 ms 4960 KB
from math import gcd
n, a, b = map(int, input().split())
pr = []
for i in range(n):
    x, y = map(int, input().split())
    pr.append((x, y))
g = gcd(a, b+1)
num = a * b // g
ev = []
ans = 0
for p in pr:
    l = p[0]
    r = p[1]
    if r - l + 1 >= num:
        ans = num
    l %= num
    r %= num
    if r < l:
        ev += [(l, 1), (num, -1), (0, 1), (r+1, -1)]
    else:
        ev += [(l, 1), (r + 1, -1)]
ev.sort()
bal = 0
last = 0
for p in ev:
    x = p[0]
    tp = p[1]
    if bal: ans += x - last
    last = x
    bal += tp
print min(num, ans)
# Verdict Execution time Memory Grader output
1 Runtime error 25 ms 4960 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 28 ms 4960 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 25 ms 4952 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 25 ms 4960 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 25 ms 4960 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 25 ms 4960 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 30 ms 4960 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 25 ms 4960 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -