n, a, b = map(int, input().split())
k = a * b
seg = []
for i in range(n):
l, r = map(int, input().split())
if r - l + 1 >= k:
seg.append([0, k - 1])
continue
l1 = l % k
r1 = r % k
if r1 < l1:
seg.append([0, r1])
seg.append([l1, k - 1])
else:
seg.append([l1, r1])
seg.sort()
mxr, res = -1, 0
for x in seg:
res += max(0, x[1] - max(mxr, x[0] - 1))
mxr = x[1]
print(res)
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
33 ms |
5208 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
29 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 |
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 |
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 |
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 |
30 ms |
5016 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
33 ms |
5208 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |