#include <bits/stdc++.h>
using namespace std;
template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;
ll n, a, b;
ll getx(ll t) {
return (t+t/b)%a;
}
ll gety(ll t) {
return t%b;
}
vector<pair<ll,ll>> v;
int main() {
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin>>n>>a>>b;
v.resize(n);
for (int i=0; i<n; i++) {
cin>>v[i].first>>v[i].second;
v[i].first %= (a*b);
v[i].second %= (a*b);
}
vector<ll> hit(a*b*2 + 10, 0);
for (int i=0; i<n; i++) {
ll l = v[i].first;
ll r = v[i].second;
if (r<l) r+= (a*b);
hit[l]++;
hit[r+1]--;
}
for (int i=1; i<(int)hit.size(); i++) {
hit[i]+=hit[i-1];
}
vector<ll> res(a*b, 0);
for (int i=0; i<(int)hit.size(); i++) {
if (hit[i]>0) {
res[i%(a*b)]=1;
}
}
ll ans = accumulate(res.begin(), res.end(), 0);
out(ans);
// for (int t=1; t<=100; t++) {
// ll x = getx(t);
// ll y = gety(t);
// cout<<t<<": "<<x<<" "<<y<<endl;
// }
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
129 ms |
152696 KB |
Output is correct |
3 |
Correct |
108 ms |
117240 KB |
Output is correct |
4 |
Incorrect |
14 ms |
11648 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Runtime error |
242 ms |
524292 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
28 ms |
23040 KB |
Output is correct |
3 |
Correct |
28 ms |
23416 KB |
Output is correct |
4 |
Correct |
24 ms |
19456 KB |
Output is correct |
5 |
Correct |
353 ms |
39544 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
462 ms |
45168 KB |
Output is correct |
3 |
Runtime error |
444 ms |
32632 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
462 ms |
45168 KB |
Output is correct |
3 |
Runtime error |
444 ms |
32632 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
462 ms |
45168 KB |
Output is correct |
3 |
Runtime error |
444 ms |
32632 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Runtime error |
283 ms |
524288 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
129 ms |
152696 KB |
Output is correct |
3 |
Correct |
108 ms |
117240 KB |
Output is correct |
4 |
Incorrect |
14 ms |
11648 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |