#include <iostream>
#include <set>
using namespace std;
struct duo
{
long long x;
long long y;
};
bool operator < (duo A, duo B)
{
if(A.x == B.x) return A.y < B.y;
return A.x < B.x;
}
int main()
{
long long n, A, B;
cin >> n >> A >> B;
long long l[n+1], r[n+1];
for(int i = 1; i <= n; i++) cin >> l[i] >> r[i];
set<duo> S;
for(int i = 1; i <= n; i++) for(long long t = l[i]; t <= r[i]; t++) S.insert(duo{(t + (t/B)) % A, t % B});
cout << S.size() << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
76 ms |
12920 KB |
Output is correct |
3 |
Correct |
116 ms |
18424 KB |
Output is correct |
4 |
Correct |
2 ms |
896 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
512 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
9 ms |
1260 KB |
Output is correct |
10 |
Correct |
1 ms |
256 KB |
Output is correct |
11 |
Correct |
0 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
256 KB |
Output is correct |
13 |
Correct |
1 ms |
256 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
43 ms |
7032 KB |
Output is correct |
16 |
Correct |
59 ms |
7224 KB |
Output is correct |
17 |
Correct |
327 ms |
11892 KB |
Output is correct |
18 |
Correct |
1 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Runtime error |
2902 ms |
524292 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
166 ms |
32376 KB |
Output is correct |
3 |
Correct |
184 ms |
32120 KB |
Output is correct |
4 |
Correct |
143 ms |
30584 KB |
Output is correct |
5 |
Execution timed out |
5058 ms |
81648 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
3207 ms |
91956 KB |
Output is correct |
3 |
Execution timed out |
5091 ms |
508304 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
3207 ms |
91956 KB |
Output is correct |
3 |
Execution timed out |
5091 ms |
508304 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
3207 ms |
91956 KB |
Output is correct |
3 |
Execution timed out |
5091 ms |
508304 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Runtime error |
2048 ms |
524292 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
76 ms |
12920 KB |
Output is correct |
3 |
Correct |
116 ms |
18424 KB |
Output is correct |
4 |
Correct |
2 ms |
896 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
512 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
9 ms |
1260 KB |
Output is correct |
10 |
Correct |
1 ms |
256 KB |
Output is correct |
11 |
Correct |
0 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
256 KB |
Output is correct |
13 |
Correct |
1 ms |
256 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
43 ms |
7032 KB |
Output is correct |
16 |
Correct |
59 ms |
7224 KB |
Output is correct |
17 |
Correct |
327 ms |
11892 KB |
Output is correct |
18 |
Correct |
1 ms |
256 KB |
Output is correct |
19 |
Correct |
1 ms |
256 KB |
Output is correct |
20 |
Runtime error |
2902 ms |
524292 KB |
Execution killed with signal 9 |
21 |
Halted |
0 ms |
0 KB |
- |