#include <bits/stdc++.h>
using namespace std;
struct interv{
long long l, r;
bool operator < (const interv &aux)const{
if(l != aux.l) return l < aux.l;
return r < aux.r;
}
};
interv a[2000005];
int n;
long long A, B;
int main()
{
cin >> n >> A >> B;
double lg1 = log2((double)A), lg2 = log2((double)B);
long long prod = 0;
if(lg1 + lg2 <= 63) prod = 1LL * A * B;
int m = n;
for(int i = 1; i <= n ; ++i){
cin >> a[i].l >> a[i].r;
if(prod != 0){
a[i].l %= prod, a[i].r %= prod;
if(a[i].r < a[i].l) a[++m].l = 0, a[m].r = a[i].r, a[i].r = prod - 1;
}
}
n = m;
sort(a + 1, a + n + 1);
long long Sol = 0, l = -2, r = -3;
for(int i = 1; i <= n ; ++i){
if(r < a[i].l){
Sol = Sol + (r - l + 1);
l = a[i].l; r = a[i].r;
}
else r = max(r, a[i].r);
}
Sol = Sol + (r - l + 1);
cout << Sol;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
28 ms |
888 KB |
Output is correct |
3 |
Correct |
28 ms |
888 KB |
Output is correct |
4 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
4 ms |
376 KB |
Output is correct |
5 |
Correct |
1859 ms |
16172 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
256 KB |
Output is correct |
2 |
Correct |
2635 ms |
16332 KB |
Output is correct |
3 |
Incorrect |
2644 ms |
16364 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
256 KB |
Output is correct |
2 |
Correct |
2635 ms |
16332 KB |
Output is correct |
3 |
Incorrect |
2644 ms |
16364 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
256 KB |
Output is correct |
2 |
Correct |
2635 ms |
16332 KB |
Output is correct |
3 |
Incorrect |
2644 ms |
16364 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
266 ms |
3648 KB |
Output is correct |
3 |
Correct |
269 ms |
3608 KB |
Output is correct |
4 |
Correct |
2701 ms |
16160 KB |
Output is correct |
5 |
Correct |
267 ms |
3424 KB |
Output is correct |
6 |
Correct |
268 ms |
3448 KB |
Output is correct |
7 |
Correct |
274 ms |
3448 KB |
Output is correct |
8 |
Correct |
273 ms |
3408 KB |
Output is correct |
9 |
Correct |
273 ms |
3252 KB |
Output is correct |
10 |
Correct |
271 ms |
3320 KB |
Output is correct |
11 |
Correct |
268 ms |
3396 KB |
Output is correct |
12 |
Correct |
261 ms |
3732 KB |
Output is correct |
13 |
Correct |
266 ms |
3704 KB |
Output is correct |
14 |
Correct |
2668 ms |
16304 KB |
Output is correct |
15 |
Incorrect |
269 ms |
3528 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
28 ms |
888 KB |
Output is correct |
3 |
Correct |
28 ms |
888 KB |
Output is correct |
4 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |