#include <bits/stdc++.h>
using namespace std;
long long i,j,a,b,tt;
long long x,r,m,n,s,t,k,l,y,z,v=234560;
set <pair<long long,long long>> p,c,d,e;
int main(){
cin >> n>>a>>b;
if (b > 1){
for (i = 0; i<n; i ++){
cin >>x>>y;
for (j = x; j<=y; j ++){
l = (j+j/b)%a;
m=j%b;
p.insert({l,m});
}
}
cout << p.size();
return 0;
}
if (a%2 == 0)
a/=2;
for (i = 0; i<n; i ++){
cin >>x>>y;
if (y-x+1>=a){
cout << a;
return 0;
}
x%=a;
y%=a;
if (x <=y){
p.insert({x,y});
}
else {
p.insert({0,y});
p.insert({x,a-1});
}
}
t = -1;
while (p.size()){
auto u=*p.begin();
p.erase(*p.begin());
x=u.first;
y=u.second;
t=max(t,x-1);
s+=max(y-t,0ll);
t=max(y,t);
}
cout << s;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
69 ms |
12280 KB |
Output is correct |
3 |
Correct |
90 ms |
17916 KB |
Output is correct |
4 |
Correct |
4 ms |
896 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
512 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
9 ms |
1152 KB |
Output is correct |
10 |
Correct |
1 ms |
256 KB |
Output is correct |
11 |
Correct |
0 ms |
256 KB |
Output is correct |
12 |
Correct |
1 ms |
256 KB |
Output is correct |
13 |
Correct |
0 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 |
52 ms |
6776 KB |
Output is correct |
17 |
Correct |
234 ms |
6648 KB |
Output is correct |
18 |
Correct |
0 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Runtime error |
2844 ms |
524292 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
142 ms |
32360 KB |
Output is correct |
3 |
Correct |
164 ms |
31992 KB |
Output is correct |
4 |
Correct |
144 ms |
30572 KB |
Output is correct |
5 |
Execution timed out |
5079 ms |
62560 KB |
Time limit exceeded |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
2383 ms |
62928 KB |
Output is correct |
3 |
Correct |
2560 ms |
62972 KB |
Output is correct |
4 |
Correct |
2469 ms |
62940 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
2383 ms |
62928 KB |
Output is correct |
3 |
Correct |
2560 ms |
62972 KB |
Output is correct |
4 |
Correct |
2469 ms |
62940 KB |
Output is correct |
5 |
Correct |
0 ms |
256 KB |
Output is correct |
6 |
Runtime error |
2440 ms |
524292 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
2383 ms |
62928 KB |
Output is correct |
3 |
Correct |
2560 ms |
62972 KB |
Output is correct |
4 |
Correct |
2469 ms |
62940 KB |
Output is correct |
5 |
Correct |
0 ms |
256 KB |
Output is correct |
6 |
Correct |
401 ms |
66344 KB |
Output is correct |
7 |
Runtime error |
2153 ms |
524292 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Runtime error |
1515 ms |
524292 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
69 ms |
12280 KB |
Output is correct |
3 |
Correct |
90 ms |
17916 KB |
Output is correct |
4 |
Correct |
4 ms |
896 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
512 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
9 ms |
1152 KB |
Output is correct |
10 |
Correct |
1 ms |
256 KB |
Output is correct |
11 |
Correct |
0 ms |
256 KB |
Output is correct |
12 |
Correct |
1 ms |
256 KB |
Output is correct |
13 |
Correct |
0 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 |
52 ms |
6776 KB |
Output is correct |
17 |
Correct |
234 ms |
6648 KB |
Output is correct |
18 |
Correct |
0 ms |
256 KB |
Output is correct |
19 |
Correct |
0 ms |
256 KB |
Output is correct |
20 |
Runtime error |
2844 ms |
524292 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
21 |
Halted |
0 ms |
0 KB |
- |