#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define debug(a) cout << #a << " = " << a << endl
#define debugsl(a) cout << #a << " = " << a << ", "
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define repa(i,a,b) for(int i = (a); i >= (b); i--)
#define LIM (1ll << 62)
lli a,b,n,cont,x,y,mult,ini,res;
vector<pair<lli,lli> > orden;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> a >> b;
mult = LIM/a;
if (mult >= b) mult = a*b;
else mult = LIM;
rep(i,1,n) {
cin >> x >> y;
x %= mult;
y %= mult;
if (x > y) {
orden.push_back({0,1});
orden.push_back({mult-1,2});
}
orden.push_back({x,1});
orden.push_back({y,2});
}
sort(orden.begin(), orden.end());
ini = -1;
cont = 0;
res = 0;
for (auto act:orden) {
if (act.second == 1) {
cont++;
if (ini == -1) ini = act.first;
}
else cont--;
if (cont == 0) {
res += (act.first - ini) + 1;
ini = -1;
}
}
cout << res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
5 ms |
1228 KB |
Output is correct |
3 |
Correct |
7 ms |
1240 KB |
Output is correct |
4 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
324 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
376 KB |
Output is correct |
5 |
Correct |
350 ms |
37800 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
512 ms |
38816 KB |
Output is correct |
3 |
Incorrect |
452 ms |
38712 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
512 ms |
38816 KB |
Output is correct |
3 |
Incorrect |
452 ms |
38712 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
512 ms |
38816 KB |
Output is correct |
3 |
Incorrect |
452 ms |
38712 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
52 ms |
7232 KB |
Output is correct |
3 |
Correct |
51 ms |
7244 KB |
Output is correct |
4 |
Correct |
617 ms |
38828 KB |
Output is correct |
5 |
Correct |
50 ms |
7292 KB |
Output is correct |
6 |
Correct |
57 ms |
7264 KB |
Output is correct |
7 |
Correct |
65 ms |
7196 KB |
Output is correct |
8 |
Correct |
61 ms |
7224 KB |
Output is correct |
9 |
Correct |
49 ms |
7200 KB |
Output is correct |
10 |
Correct |
56 ms |
7212 KB |
Output is correct |
11 |
Correct |
55 ms |
7280 KB |
Output is correct |
12 |
Correct |
49 ms |
7204 KB |
Output is correct |
13 |
Correct |
60 ms |
7252 KB |
Output is correct |
14 |
Correct |
549 ms |
38764 KB |
Output is correct |
15 |
Incorrect |
71 ms |
7276 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
5 ms |
1228 KB |
Output is correct |
3 |
Correct |
7 ms |
1240 KB |
Output is correct |
4 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |