#include<bits/stdc++.h>
using namespace std;
const int N = 1e6 + 6;
long long l[N] , r[N] , fir , las , a , b , sum = 0;
int n;
int main(){
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> n >> a >> b;
if(n == 1){
cin >> fir >> las;
cout << ((las - fir + 1) / b >= a ? a * b : las - fir + 1) << '\n';
return 0;
}
for(int i = 0 ; i < n ; i++){
cin >> l[i] >> r[i];
sum += r[i] - l[i] + 1;
}
if(sum < N){
map<pair<long long , long long> , int> mp;
for(int i = 0 ; i < n ; i++)
for(long long j = l[i] ; j <= r[i] ; j++)
mp[{(j + j / b) % a , j % b}]++;
cout << (int)mp.size() << '\n';
return 0;
}
cout << 0 << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
44 ms |
12860 KB |
Output is correct |
3 |
Correct |
62 ms |
18380 KB |
Output is correct |
4 |
Correct |
2 ms |
852 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
2 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
460 KB |
Output is correct |
9 |
Correct |
7 ms |
1108 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
34 ms |
6988 KB |
Output is correct |
16 |
Correct |
24 ms |
7244 KB |
Output is correct |
17 |
Correct |
58 ms |
8896 KB |
Output is correct |
18 |
Correct |
0 ms |
324 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
1 ms |
324 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
328 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
324 KB |
Output is correct |
2 |
Correct |
121 ms |
32268 KB |
Output is correct |
3 |
Correct |
156 ms |
32124 KB |
Output is correct |
4 |
Correct |
106 ms |
30652 KB |
Output is correct |
5 |
Incorrect |
227 ms |
15920 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
316 ms |
16072 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
316 ms |
16072 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
316 ms |
16072 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
31 ms |
2584 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
44 ms |
12860 KB |
Output is correct |
3 |
Correct |
62 ms |
18380 KB |
Output is correct |
4 |
Correct |
2 ms |
852 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
2 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
460 KB |
Output is correct |
9 |
Correct |
7 ms |
1108 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
34 ms |
6988 KB |
Output is correct |
16 |
Correct |
24 ms |
7244 KB |
Output is correct |
17 |
Correct |
58 ms |
8896 KB |
Output is correct |
18 |
Correct |
0 ms |
324 KB |
Output is correct |
19 |
Correct |
1 ms |
328 KB |
Output is correct |
20 |
Correct |
1 ms |
324 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
328 KB |
Output is correct |
23 |
Correct |
1 ms |
212 KB |
Output is correct |
24 |
Correct |
0 ms |
324 KB |
Output is correct |
25 |
Correct |
121 ms |
32268 KB |
Output is correct |
26 |
Correct |
156 ms |
32124 KB |
Output is correct |
27 |
Correct |
106 ms |
30652 KB |
Output is correct |
28 |
Incorrect |
227 ms |
15920 KB |
Output isn't correct |
29 |
Halted |
0 ms |
0 KB |
- |