#include <bits/stdc++.h>
#define int long long
using namespace std;
int n,a,b;
vector<pair<int,int>> e;
int fr[1000005];
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin>>n>>a>>b;
for(int i=1;i<=n;i++)
{
int l,r;
cin>>l>>r;
if(r - l + 1 >= a * b)
{
cout<<a * b<<'\n';
return 0;
}
l %= a * b;
r %= a * b;
if(l <= r)
{
e.push_back({l,r});
}
else
{
e.push_back({0,r});
e.push_back({l,a*b-1});
}
}
sort(e.begin(),e.end());
for(auto it : e)
{
++fr[it.first];
--fr[it.second + 1];
}
int rez = (fr[0] > 0);
for(int i=1;i<a*b;i++)
{
fr[i] += fr[i-1];
rez += (fr[i] > 0);
}
cout<<rez<<'\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Runtime error |
6 ms |
2056 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
328 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Runtime error |
1 ms |
452 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
328 KB |
Output is correct |
2 |
Correct |
8 ms |
7892 KB |
Output is correct |
3 |
Correct |
6 ms |
8020 KB |
Output is correct |
4 |
Correct |
6 ms |
6612 KB |
Output is correct |
5 |
Correct |
322 ms |
49212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Runtime error |
443 ms |
47028 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Runtime error |
443 ms |
47028 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Runtime error |
443 ms |
47028 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Runtime error |
44 ms |
4552 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Runtime error |
6 ms |
2056 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |