#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
#define debug(x) cout << #x << ": " << x << endl
#else
#define debug(x)
#endif
ll inf = 2e18;
ll n,a,b,p;
map<ll,ll> mp;
ll bef,curr,ans;
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> a >> b;
ll gc = __gcd(a,b+1LL);
if(a/gc>inf/b){
p = 1e18;
}
else{
p = a/gc*b;
}
for(ll i=1;i<=n;i++){
ll c,d;
cin >> c >> d;
if(d-c+1LL>=p){
return 0;
}
else{
c %= p;
d %= p;
if(c<=d){
mp[c]++;
mp[d+1LL]--;
}
else{
mp[0]++;
mp[d+1LL]--;
mp[c]++;
mp[p]--;
}
}
}
for(auto it=mp.begin();it!=mp.end();it++){
if(curr){
ans += it->first-bef;
}
bef = it->first;
curr += it->second;
}
cout << ans << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |