#include<bits/stdc++.h>
#include <deque>
#include <cmath>
using namespace std;
#define ll long long
/*freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);*/
long long x , y , z , i , j , n , m , k , s1 , s2 , s3 , s4 , s5 , s6 , mod , l , r , t , maxx , minn , sx , so , sum , mid , ans , puk , par , chi , sz , choc1 , choc2 , len , depth ;
double u , v , w , x1 , x2 , x3 , x4 , z1 , z2 , z3 , h , huh ;
string s ;
string q ;
string p ;
string sq [ 1045 ] ;
char ch ;
char cha ;
vector < long long > vc ;
vector < long long > cv ;
vector < long long > vv ;
vector < long long > cc ;
long long dp [ 200045 ] [ 6 ] ;
long long tmp [ 300045 ] ;
pair < long long , long long > aa [ 2000045 ] ;
long long a [ 300045 ] ;
long long b [ 200045 ] ;
long long c [ 200045 ] ;
map < long long , long long > mp ;
int main() {
cin >> n >> x >> y ;
z = __gcd ( x , y + 1 ) ;
z = x / z ;
if ( z > 1000000000000000000 / y ) {
k = 1000000000000000001 ;
}
else {
k = k * y ;
}
x = 0 ;
for ( i = 1 ; i <= n ; i ++ ) {
cin >> l >> y ;
if ( r - l + 1 >= k ) {
cout << k ;
exit (0) ;
}
l %= k ;
r %= k ;
if ( l <= r ) {
x ++ ;
aa [ x ] . first = l ;
aa [ x ] . second = r ;
}
else {
x ++ ;
aa [ x ] . first = l ;
aa [ x ] . second = k - 1 ;
x ++ ;
aa [ x ] . first = 0 ;
aa [ x ] . second = r ;
}
}
sort ( aa + 1 , aa + x + 1 ) ;
r = -1 ;
ans = 0 ;
for ( i = 1 ; i <= x ; i ++ ) {
r = max ( r , aa [ i ] . first - 1 ) ;
ans += max ( aa [ i ] . second - r , so ) ;
r = max ( aa [ i ] . second , r ) ;
}
cout << ans ;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
512 KB |
Execution killed with signal 8 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
512 KB |
Execution killed with signal 8 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
512 KB |
Execution killed with signal 8 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
512 KB |
Execution killed with signal 8 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
512 KB |
Execution killed with signal 8 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
512 KB |
Execution killed with signal 8 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |