n,a,b = map(int, input().split())
ranges = []
for i in range(n):
ranges.append(list(map(int, input().split())))
newranges = []
flag = False
for i in range(n):
ranges[i] = [ranges[i][0]%(a*b), ranges[i][1]%(a*b)]
if ranges[i][0]>ranges[i][1]:
newranges.append([ranges[i][0]%(a*b),a*b])
newranges.append([0,ranges[i][1]%(a*b)])
flag = True
else:
newranges.append(ranges[i])
newranges.sort()
ans = 0
cur = a*b
while newranges:
sus = newranges.pop()
ans += min(cur,sus[1])-sus[0]+1
cur = sus[0]-1
print(ans-flag)
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
18192 KB |
Output is correct |
2 |
Incorrect |
115 ms |
26828 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
18132 KB |
Output is correct |
2 |
Incorrect |
36 ms |
18184 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
39 ms |
18212 KB |
Output is correct |
2 |
Incorrect |
75 ms |
19708 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
18172 KB |
Output is correct |
2 |
Correct |
2536 ms |
283124 KB |
Output is correct |
3 |
Incorrect |
2439 ms |
283052 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
18172 KB |
Output is correct |
2 |
Correct |
2536 ms |
283124 KB |
Output is correct |
3 |
Incorrect |
2439 ms |
283052 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
18172 KB |
Output is correct |
2 |
Correct |
2536 ms |
283124 KB |
Output is correct |
3 |
Incorrect |
2439 ms |
283052 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
34 ms |
18228 KB |
Output is correct |
2 |
Correct |
330 ms |
46308 KB |
Output is correct |
3 |
Correct |
341 ms |
46344 KB |
Output is correct |
4 |
Correct |
2413 ms |
283008 KB |
Output is correct |
5 |
Correct |
331 ms |
46340 KB |
Output is correct |
6 |
Correct |
322 ms |
46252 KB |
Output is correct |
7 |
Correct |
324 ms |
46292 KB |
Output is correct |
8 |
Correct |
318 ms |
46436 KB |
Output is correct |
9 |
Correct |
315 ms |
46280 KB |
Output is correct |
10 |
Correct |
367 ms |
46340 KB |
Output is correct |
11 |
Correct |
310 ms |
46452 KB |
Output is correct |
12 |
Correct |
322 ms |
46956 KB |
Output is correct |
13 |
Correct |
317 ms |
46412 KB |
Output is correct |
14 |
Incorrect |
2504 ms |
278712 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
18192 KB |
Output is correct |
2 |
Incorrect |
115 ms |
26828 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |