#include <bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long n,a,b;
cin >> n >> a >> b;
long long l[n];
long long r[n];
long long rez=0;
set< pair<long long,long long> > s;
for(int i=0;i<n;i++)
{
cin >> l[i]>>r[i];
for(long long t=l[i];t<=r[i];t++)
{
long long y=t%b;
long long x=(t+t/b)%a;
if(!s.count(make_pair(x,y)))
{
s.insert(make_pair(x,y));
rez++;
}
}
}
cout << rez;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
94 ms |
12936 KB |
Output is correct |
3 |
Correct |
148 ms |
18440 KB |
Output is correct |
4 |
Correct |
5 ms |
860 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
3 ms |
504 KB |
Output is correct |
8 |
Correct |
3 ms |
376 KB |
Output is correct |
9 |
Correct |
14 ms |
1148 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
81 ms |
7132 KB |
Output is correct |
16 |
Correct |
53 ms |
7288 KB |
Output is correct |
17 |
Correct |
110 ms |
9336 KB |
Output is correct |
18 |
Correct |
2 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
348 KB |
Output is correct |
2 |
Execution timed out |
5037 ms |
391788 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
256 ms |
32380 KB |
Output is correct |
3 |
Correct |
274 ms |
32248 KB |
Output is correct |
4 |
Correct |
256 ms |
30660 KB |
Output is correct |
5 |
Execution timed out |
5079 ms |
62612 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
917 ms |
80876 KB |
Output is correct |
3 |
Runtime error |
4576 ms |
524292 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
917 ms |
80876 KB |
Output is correct |
3 |
Runtime error |
4576 ms |
524292 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
917 ms |
80876 KB |
Output is correct |
3 |
Runtime error |
4576 ms |
524292 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Runtime error |
2798 ms |
524292 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
94 ms |
12936 KB |
Output is correct |
3 |
Correct |
148 ms |
18440 KB |
Output is correct |
4 |
Correct |
5 ms |
860 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
3 ms |
504 KB |
Output is correct |
8 |
Correct |
3 ms |
376 KB |
Output is correct |
9 |
Correct |
14 ms |
1148 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
81 ms |
7132 KB |
Output is correct |
16 |
Correct |
53 ms |
7288 KB |
Output is correct |
17 |
Correct |
110 ms |
9336 KB |
Output is correct |
18 |
Correct |
2 ms |
256 KB |
Output is correct |
19 |
Correct |
2 ms |
348 KB |
Output is correct |
20 |
Execution timed out |
5037 ms |
391788 KB |
Time limit exceeded |
21 |
Halted |
0 ms |
0 KB |
- |