#include<bits/stdc++.h>
#include<ext/rope>
using namespace std;
using namespace __gnu_cxx;
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
#define fopen freopen("input.txt", "r", stdin)
#define eb emplace_back
#define em emplace
#define prec(a) cout<<fixed;cout.precision(a);
#define all(a) (a).begin(), (a).end()
typedef long long ll;typedef long double ld;typedef unsigned long long ul;typedef unsigned int ui;typedef pair<int,int> pii;typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tiii;
const ll INF = 2e18;
const int inf = 2e9;
template<class T>
void pr(T t) {cerr << t << " ";}
template<class T, class ...Args>
void pr(T a, Args ...args) {cerr << a << " ";pr(args...);}
template<class ...Args>
void prl(Args ...args) {pr(args...);cerr << endl;}
int n;
ll A, B, m, ans;
double tmp;
bool flag;
vector<pll> h;
int main(){
fastio;
cin>>n>>A>>B;
tmp = (double)A*B;
if(tmp>1e18) m = 2e18;
else m = A*B;
for(int i=1;i<=n;i++){
ll a, b;
cin>>a>>b;
if(b-a+1>=m){
flag=true;
continue;
}
a%=m;b%=m;
if(a<=b) h.eb(a,b);
else{
h.eb(a,m-1);h.eb(0,b);
}
}
if(flag){
cout<<m;return 0;
}
sort(all(h));
ll ma=-1;
for(auto i:h){
ans = ans + max(i.fi-ma-1, 0LL);
ma = max(ma, i.se);
}
ans = ans + m-1-ma;
cout<<m-ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
11 ms |
1020 KB |
Output is correct |
3 |
Correct |
11 ms |
1144 KB |
Output is correct |
4 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
504 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
6 ms |
376 KB |
Output is correct |
4 |
Correct |
6 ms |
376 KB |
Output is correct |
5 |
Execution timed out |
152 ms |
16596 KB |
Time limit exceeded (wall clock) |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
508 KB |
Output is correct |
2 |
Correct |
558 ms |
27476 KB |
Output is correct |
3 |
Incorrect |
554 ms |
35796 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
508 KB |
Output is correct |
2 |
Correct |
558 ms |
27476 KB |
Output is correct |
3 |
Incorrect |
554 ms |
35796 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
508 KB |
Output is correct |
2 |
Correct |
558 ms |
27476 KB |
Output is correct |
3 |
Incorrect |
554 ms |
35796 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
61 ms |
5736 KB |
Output is correct |
3 |
Correct |
64 ms |
5740 KB |
Output is correct |
4 |
Correct |
603 ms |
27476 KB |
Output is correct |
5 |
Correct |
60 ms |
5740 KB |
Output is correct |
6 |
Correct |
64 ms |
6088 KB |
Output is correct |
7 |
Correct |
63 ms |
5736 KB |
Output is correct |
8 |
Correct |
61 ms |
5740 KB |
Output is correct |
9 |
Correct |
59 ms |
5736 KB |
Output is correct |
10 |
Correct |
61 ms |
5736 KB |
Output is correct |
11 |
Correct |
64 ms |
5736 KB |
Output is correct |
12 |
Correct |
55 ms |
5736 KB |
Output is correct |
13 |
Correct |
64 ms |
5860 KB |
Output is correct |
14 |
Correct |
575 ms |
27476 KB |
Output is correct |
15 |
Incorrect |
61 ms |
5760 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
11 ms |
1020 KB |
Output is correct |
3 |
Correct |
11 ms |
1144 KB |
Output is correct |
4 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |