#include <bits/stdc++.h>
using namespace std;
void just_do_it();
int main() {
#ifdef KAMIRULEZ
freopen("kamirulez.inp", "r", stdin);
freopen("kamirulez.out", "w", stdout);
#endif
ios_base::sync_with_stdio(0);
cin.tie(0);
just_do_it();
return 0;
}
const int maxN = 1e6 + 20;
const long long inf = 1e18L + 20;
long long L[maxN];
long long R[maxN];
void just_do_it() {
int N;
long long A, B;
cin >> N >> A >> B;
for (int i = 0; i < N; i++) {
cin >> L[i] >> R[i];
}
if (A > inf / B) {
long long res = 0;
for (int i = 0; i < N; i++) {
res += R[i] - L[i] + 1;
}
cout << res;
return;
}
set<long long> S;
for (int i = 0; i < N; i++) {
for (long long j = L[i]; j <= R[i]; j++) {
S.insert(j % (A * B));
}
}
cout << S.size();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
38 ms |
9808 KB |
Output is correct |
3 |
Correct |
62 ms |
14068 KB |
Output is correct |
4 |
Incorrect |
2 ms |
852 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Runtime error |
4086 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
103 ms |
24356 KB |
Output is correct |
3 |
Correct |
90 ms |
24208 KB |
Output is correct |
4 |
Correct |
86 ms |
23092 KB |
Output is correct |
5 |
Execution timed out |
5070 ms |
62912 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
525 ms |
64648 KB |
Output is correct |
3 |
Runtime error |
2578 ms |
524288 KB |
Execution killed with signal 9 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
525 ms |
64648 KB |
Output is correct |
3 |
Runtime error |
2578 ms |
524288 KB |
Execution killed with signal 9 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
525 ms |
64648 KB |
Output is correct |
3 |
Runtime error |
2578 ms |
524288 KB |
Execution killed with signal 9 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Runtime error |
2384 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
38 ms |
9808 KB |
Output is correct |
3 |
Correct |
62 ms |
14068 KB |
Output is correct |
4 |
Incorrect |
2 ms |
852 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |