#include <iostream>
#include <map>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
ll N,A,B;
ll L[1000006],R[1000006];
ll x,y;
map<ll,ll> S;
ll ans,K;
int main(){
cin>>N>>A>>B;
ll M=(A*B);
for(int i=0;i<N;i++){
cin>>L[i]>>R[i];
x=L[i]%M;
y=R[i]%M;
if(y<x){
if(R[i]-L[i]>=M){
S[0]++;
S[M]--;
}
else{
S[0]++;
S[y+1]--;
S[x]++;
S[M]--;
}
}
else{
S[x]++;
S[y+1]--;
}
}
pll q=*S.begin();
for(pll p:S){
if(K)
ans+=p.first-q.first;
K+=p.second;
q=p;
}
cout<<ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
31 ms |
1364 KB |
Output is correct |
3 |
Correct |
32 ms |
1480 KB |
Output is correct |
4 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
256 KB |
Output is correct |
2 |
Correct |
6 ms |
504 KB |
Output is correct |
3 |
Correct |
5 ms |
504 KB |
Output is correct |
4 |
Correct |
5 ms |
504 KB |
Output is correct |
5 |
Correct |
1832 ms |
16196 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
3106 ms |
78824 KB |
Output is correct |
3 |
Incorrect |
3244 ms |
80632 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
3106 ms |
78824 KB |
Output is correct |
3 |
Incorrect |
3244 ms |
80632 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
3106 ms |
78824 KB |
Output is correct |
3 |
Incorrect |
3244 ms |
80632 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
312 ms |
8312 KB |
Output is correct |
3 |
Correct |
318 ms |
10816 KB |
Output is correct |
4 |
Correct |
3261 ms |
80296 KB |
Output is correct |
5 |
Correct |
316 ms |
11064 KB |
Output is correct |
6 |
Correct |
317 ms |
10992 KB |
Output is correct |
7 |
Correct |
320 ms |
10840 KB |
Output is correct |
8 |
Correct |
314 ms |
10460 KB |
Output is correct |
9 |
Correct |
310 ms |
10396 KB |
Output is correct |
10 |
Correct |
305 ms |
10452 KB |
Output is correct |
11 |
Correct |
332 ms |
10588 KB |
Output is correct |
12 |
Correct |
306 ms |
10488 KB |
Output is correct |
13 |
Correct |
321 ms |
10588 KB |
Output is correct |
14 |
Correct |
3335 ms |
80296 KB |
Output is correct |
15 |
Incorrect |
324 ms |
10592 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
31 ms |
1364 KB |
Output is correct |
3 |
Correct |
32 ms |
1480 KB |
Output is correct |
4 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |