#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define double long double
using pii = pair<int, int>;
template<typename T>
using Prior = priority_queue<T>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back
#define fastIO() ios_base::sync_with_stdio(false), cin.tie(0)
int32_t main() {
fastIO();
int n, A, B;
cin >> n >> A >> B;
if (A % 2 == 0) A /= 2;
map<int, int> rng;
for (int i = 0; i < n; ++i) {
int l, r;
cin >> l >> r;
if (r - l + 1 >= A) {++rng[0], --rng[A]; continue;}
l %= A, r %= A;
if (l <= r) ++rng[l], --rng[r + 1];
else ++rng[l], --rng[A], ++rng[0], --rng[r + 1];
}
// cout << "-=-=-=-=-\n";
// for (auto x : rng) cout << x.X << " " << x.Y << "\n";
// cout << "-=-=-=-=-\n";
int ans = 0, lst_num = 0, lst_sum = 0;
for (auto x : rng) {
x.Y += lst_sum;
if (lst_sum > 0) ans += x.X - lst_num;
lst_num = x.X;
lst_sum = x.Y;
}
cout << ans << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Incorrect |
6 ms |
768 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Incorrect |
1 ms |
512 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
804 ms |
64888 KB |
Output is correct |
3 |
Correct |
867 ms |
82520 KB |
Output is correct |
4 |
Correct |
888 ms |
82444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
804 ms |
64888 KB |
Output is correct |
3 |
Correct |
867 ms |
82520 KB |
Output is correct |
4 |
Correct |
888 ms |
82444 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Incorrect |
842 ms |
82492 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
804 ms |
64888 KB |
Output is correct |
3 |
Correct |
867 ms |
82520 KB |
Output is correct |
4 |
Correct |
888 ms |
82444 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Incorrect |
64 ms |
6008 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Incorrect |
59 ms |
4472 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Incorrect |
6 ms |
768 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |