#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
const int maxn = 1e6 + 10;
int n;
ll l[maxn], r[maxn];
ll A, B;
void solve()
{
cin >> n >> A >> B;
for (int i = 1; i <= n; i ++)
{
cin >> l[i] >> r[i];
}
if (n == 1)
{
ll ans = (r[1] - l[1] + 1);
if (ans / B > A)
ans = min(ans, A * B);
cout << ans << endl;
return;
}
if ((ll)(2e18) / B < A)
{
ll ans = 0;
for (int i = 1; i <= n; i ++)
ans = ans + (r[i] - l[i] + 1);
cout << ans << endl;
return;
}
unordered_set < ll > st;
for (int i = 1; i <= n; i ++)
{
for (ll j = l[i]; j <= r[i]; j ++)
{
st.insert(j % (A * B));
}
}
cout << st.size() << endl;
}
int main()
{
solve();
return 0;
}
/**
7 3
4 1 3 4 0 2 3
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
31 ms |
9932 KB |
Output is correct |
3 |
Correct |
33 ms |
11940 KB |
Output is correct |
4 |
Incorrect |
1 ms |
852 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 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
40 ms |
21816 KB |
Output is correct |
3 |
Correct |
49 ms |
21788 KB |
Output is correct |
4 |
Correct |
44 ms |
20976 KB |
Output is correct |
5 |
Execution timed out |
5038 ms |
58296 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1491 ms |
58528 KB |
Output is correct |
3 |
Runtime error |
2178 ms |
524288 KB |
Execution killed with signal 9 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1491 ms |
58528 KB |
Output is correct |
3 |
Runtime error |
2178 ms |
524288 KB |
Execution killed with signal 9 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1491 ms |
58528 KB |
Output is correct |
3 |
Runtime error |
2178 ms |
524288 KB |
Execution killed with signal 9 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Runtime error |
912 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
31 ms |
9932 KB |
Output is correct |
3 |
Correct |
33 ms |
11940 KB |
Output is correct |
4 |
Incorrect |
1 ms |
852 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |