#include<bits/stdc++.h>
#define lli long long int
#define int long long int
#define pii pair<int, int>
#ifdef LOCAL
#define debug(a) cout<<#a<<' '<<a<<endl;
#endif
#ifndef LOCAL
#define debug(a) ;
#endif
using namespace std;
void faster(void)
{
ios_base::sync_with_stdio(false);
cin.tie();
cout.tie();
}
int lcm(int a, int b)
{
return (a*b)/__gcd(a,b);
}
map<pii, bool> q;
int32_t main()
{
#ifdef LOCAL
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
pii x;
vector<pii> v;
int i, n, A, B, l, r, mx;
cin >> n >> A >> B;
if(0==0)
{
int ln;
mx = B*(lcm(A, B+1)/(B+1));
for(i=1;i<=n;i++)
{
cin >> l >> r;
int ln = r-l;
l = l % (mx);
if(ln>=mx)
{
cout<<mx<<endl;
exit(0);
}
if(l+ln >= mx)
{
v.push_back(pii(l, mx-1));
v.push_back(pii(0, l+ln-mx));
}
else
{
v.push_back(pii(l, l+ln));
}
}
sort(v.begin(), v.end());
int sum=0, right=-1;
for(int i=0;i<v.size();i++)
{
if(v[i].first > right) sum += (v[i].second-v[i].first+1), right=v[i].second;
else if(v[i].second > right) sum += (v[i].second-right), right=v[i].second;
}
cout<<sum<<endl;
//debug(lmin);
//debug(rmax);
exit(0);
}
cout<<q.size()<<endl;
return 0;
}
Compilation message
strange_device.cpp: In function 'int32_t main()':
strange_device.cpp:68:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<v.size();i++)
~^~~~~~~~~
strange_device.cpp:43:7: warning: unused variable 'ln' [-Wunused-variable]
int ln;
^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
29 ms |
1080 KB |
Output is correct |
3 |
Correct |
29 ms |
1116 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
256 KB |
Output is correct |
9 |
Correct |
2 ms |
256 KB |
Output is correct |
10 |
Correct |
2 ms |
256 KB |
Output is correct |
11 |
Correct |
2 ms |
252 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
256 KB |
Output is correct |
14 |
Correct |
2 ms |
256 KB |
Output is correct |
15 |
Correct |
2 ms |
256 KB |
Output is correct |
16 |
Correct |
31 ms |
1016 KB |
Output is correct |
17 |
Correct |
270 ms |
3740 KB |
Output is correct |
18 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
252 KB |
Output is correct |
5 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
412 KB |
Output is correct |
5 |
Correct |
1863 ms |
18800 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2880 ms |
18008 KB |
Output is correct |
3 |
Correct |
2627 ms |
18256 KB |
Output is correct |
4 |
Correct |
2597 ms |
18620 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2880 ms |
18008 KB |
Output is correct |
3 |
Correct |
2627 ms |
18256 KB |
Output is correct |
4 |
Correct |
2597 ms |
18620 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
2621 ms |
18652 KB |
Output is correct |
7 |
Correct |
2626 ms |
18588 KB |
Output is correct |
8 |
Correct |
2613 ms |
18548 KB |
Output is correct |
9 |
Correct |
2685 ms |
18664 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2880 ms |
18008 KB |
Output is correct |
3 |
Correct |
2627 ms |
18256 KB |
Output is correct |
4 |
Correct |
2597 ms |
18620 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
270 ms |
5348 KB |
Output is correct |
7 |
Correct |
270 ms |
5152 KB |
Output is correct |
8 |
Correct |
268 ms |
5136 KB |
Output is correct |
9 |
Correct |
266 ms |
5168 KB |
Output is correct |
10 |
Correct |
263 ms |
5156 KB |
Output is correct |
11 |
Correct |
266 ms |
5144 KB |
Output is correct |
12 |
Correct |
273 ms |
5220 KB |
Output is correct |
13 |
Correct |
269 ms |
5248 KB |
Output is correct |
14 |
Correct |
263 ms |
5224 KB |
Output is correct |
15 |
Correct |
271 ms |
5360 KB |
Output is correct |
16 |
Correct |
272 ms |
5292 KB |
Output is correct |
17 |
Correct |
266 ms |
5220 KB |
Output is correct |
18 |
Correct |
2622 ms |
18744 KB |
Output is correct |
19 |
Correct |
2614 ms |
18728 KB |
Output is correct |
20 |
Correct |
2678 ms |
18668 KB |
Output is correct |
21 |
Correct |
272 ms |
5676 KB |
Output is correct |
22 |
Correct |
262 ms |
5228 KB |
Output is correct |
23 |
Correct |
882 ms |
14432 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
269 ms |
5660 KB |
Output is correct |
3 |
Correct |
270 ms |
5608 KB |
Output is correct |
4 |
Correct |
2745 ms |
18676 KB |
Output is correct |
5 |
Correct |
271 ms |
5448 KB |
Output is correct |
6 |
Correct |
269 ms |
5500 KB |
Output is correct |
7 |
Correct |
269 ms |
5348 KB |
Output is correct |
8 |
Correct |
281 ms |
5520 KB |
Output is correct |
9 |
Correct |
268 ms |
5224 KB |
Output is correct |
10 |
Correct |
269 ms |
5264 KB |
Output is correct |
11 |
Correct |
268 ms |
5476 KB |
Output is correct |
12 |
Correct |
264 ms |
5544 KB |
Output is correct |
13 |
Correct |
269 ms |
5348 KB |
Output is correct |
14 |
Correct |
2701 ms |
18624 KB |
Output is correct |
15 |
Correct |
275 ms |
5380 KB |
Output is correct |
16 |
Correct |
2614 ms |
18664 KB |
Output is correct |
17 |
Correct |
2609 ms |
18648 KB |
Output is correct |
18 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
29 ms |
1080 KB |
Output is correct |
3 |
Correct |
29 ms |
1116 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
256 KB |
Output is correct |
9 |
Correct |
2 ms |
256 KB |
Output is correct |
10 |
Correct |
2 ms |
256 KB |
Output is correct |
11 |
Correct |
2 ms |
252 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
256 KB |
Output is correct |
14 |
Correct |
2 ms |
256 KB |
Output is correct |
15 |
Correct |
2 ms |
256 KB |
Output is correct |
16 |
Correct |
31 ms |
1016 KB |
Output is correct |
17 |
Correct |
270 ms |
3740 KB |
Output is correct |
18 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |