#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 10;
int n;
long long a,b;
map<long long,int> ma;
set<long long> s;
int res[N];
vector<pair<long long,long long> > in;
long long rng[N],ans;
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n >> a >> b;
for(int i = 0;i < n;i++)
{
long long x,y;
cin >> x >> y;
if(y-x+1LL>=a*b){ cout << a*b; return 0; }
y++;
x%=(a*b),y%=(a*b);
if(y<x) in.push_back({0LL,y}),in.push_back({x,a*b});
else in.push_back({x,y});
s.insert(x),s.insert(y);
}
s.insert(0),s.insert(a*b);
long long prev = 0;
int id = 0;
for(auto x : s) ma[x] = ++id,rng[id-1] = x-prev,prev = x;
for(auto x : in) res[ma[x.first]]++,res[ma[x.second]]--;
for(int i = 1;i < N;i++) res[i]+=res[i-1];
for(int i = 1;i < N;i++) if(res[i]) ans+=rng[i];
cout << ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
28 ms |
9980 KB |
Output is correct |
3 |
Correct |
27 ms |
9980 KB |
Output is correct |
4 |
Incorrect |
16 ms |
8228 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
16 ms |
8192 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
16 ms |
8448 KB |
Output is correct |
3 |
Correct |
17 ms |
8320 KB |
Output is correct |
4 |
Correct |
20 ms |
8448 KB |
Output is correct |
5 |
Correct |
394 ms |
30912 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
1419 ms |
141348 KB |
Output is correct |
3 |
Incorrect |
1455 ms |
178492 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
1419 ms |
141348 KB |
Output is correct |
3 |
Incorrect |
1455 ms |
178492 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
1419 ms |
141348 KB |
Output is correct |
3 |
Incorrect |
1455 ms |
178492 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
148 ms |
22008 KB |
Output is correct |
3 |
Correct |
145 ms |
25192 KB |
Output is correct |
4 |
Correct |
1427 ms |
178632 KB |
Output is correct |
5 |
Correct |
147 ms |
25188 KB |
Output is correct |
6 |
Correct |
148 ms |
25188 KB |
Output is correct |
7 |
Correct |
146 ms |
25236 KB |
Output is correct |
8 |
Correct |
162 ms |
25188 KB |
Output is correct |
9 |
Correct |
141 ms |
25316 KB |
Output is correct |
10 |
Correct |
149 ms |
25236 KB |
Output is correct |
11 |
Correct |
160 ms |
25188 KB |
Output is correct |
12 |
Correct |
137 ms |
25212 KB |
Output is correct |
13 |
Correct |
145 ms |
25188 KB |
Output is correct |
14 |
Correct |
1450 ms |
178756 KB |
Output is correct |
15 |
Incorrect |
143 ms |
25188 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
28 ms |
9980 KB |
Output is correct |
3 |
Correct |
27 ms |
9980 KB |
Output is correct |
4 |
Incorrect |
16 ms |
8228 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |