Submission #744463

# Submission time Handle Problem Language Result Execution time Memory
744463 2023-05-18T15:17:50 Z khoquennguoiminhthuong Strange Device (APIO19_strange_device) C++14
65 / 100
481 ms 17596 KB
#include <bits/stdc++.h>
 
using namespace std;
long long lim;
int n;
long long a,b;
vector<pair<long long,long long>>vec;
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n;
cin>>a>>b;
long long v=a/__gcd(a,b+1);
if(v<=2e18/b)lim=v*b;
else lim=2e18;
for(int i=1;i<=n;i++)
{
long long l,r;cin>>l>>r;
l=l%lim;r=r%lim;
if(l<=r)vec.push_back({l,r});
else {vec.push_back({0,r});vec.push_back({l,lim-1});}
}
sort(vec.begin(),vec.end());
long long dem=0;
long long r=-2,l=-1;
for(auto v:vec)
{
if(r<v.first){dem+=r-l+1;l=v.first;r=v.second;}
else
r=max(r,v.second);
}
dem+=r-l+1;
cout<<dem;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 5 ms 1080 KB Output is correct
3 Correct 5 ms 1080 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 320 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 5 ms 1084 KB Output is correct
17 Correct 42 ms 2808 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 306 ms 17264 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 406 ms 17216 KB Output is correct
3 Correct 416 ms 17412 KB Output is correct
4 Correct 375 ms 17512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 406 ms 17216 KB Output is correct
3 Correct 416 ms 17412 KB Output is correct
4 Correct 375 ms 17512 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 415 ms 17400 KB Output is correct
7 Correct 375 ms 17324 KB Output is correct
8 Correct 387 ms 17252 KB Output is correct
9 Correct 436 ms 17596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 406 ms 17216 KB Output is correct
3 Correct 416 ms 17412 KB Output is correct
4 Correct 375 ms 17512 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 39 ms 2752 KB Output is correct
7 Correct 41 ms 2748 KB Output is correct
8 Correct 39 ms 2760 KB Output is correct
9 Correct 39 ms 2896 KB Output is correct
10 Correct 38 ms 2756 KB Output is correct
11 Correct 59 ms 2744 KB Output is correct
12 Correct 40 ms 2760 KB Output is correct
13 Correct 43 ms 2732 KB Output is correct
14 Correct 38 ms 2836 KB Output is correct
15 Correct 42 ms 2760 KB Output is correct
16 Correct 40 ms 2560 KB Output is correct
17 Correct 40 ms 2996 KB Output is correct
18 Correct 411 ms 17288 KB Output is correct
19 Correct 397 ms 17296 KB Output is correct
20 Correct 481 ms 17500 KB Output is correct
21 Correct 43 ms 2756 KB Output is correct
22 Correct 43 ms 2920 KB Output is correct
23 Correct 138 ms 9276 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 41 ms 2772 KB Output is correct
3 Correct 41 ms 2728 KB Output is correct
4 Correct 445 ms 17420 KB Output is correct
5 Correct 40 ms 2824 KB Output is correct
6 Correct 41 ms 2752 KB Output is correct
7 Correct 41 ms 2816 KB Output is correct
8 Correct 50 ms 2780 KB Output is correct
9 Correct 38 ms 2752 KB Output is correct
10 Correct 42 ms 2832 KB Output is correct
11 Correct 41 ms 2768 KB Output is correct
12 Correct 36 ms 2828 KB Output is correct
13 Correct 46 ms 2844 KB Output is correct
14 Correct 416 ms 17396 KB Output is correct
15 Correct 44 ms 2740 KB Output is correct
16 Correct 372 ms 17584 KB Output is correct
17 Correct 387 ms 17420 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 5 ms 1080 KB Output is correct
3 Correct 5 ms 1080 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 320 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 5 ms 1084 KB Output is correct
17 Correct 42 ms 2808 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Incorrect 1 ms 212 KB Output isn't correct
21 Halted 0 ms 0 KB -