Submission #744460

# Submission time Handle Problem Language Result Execution time Memory
744460 2023-05-18T15:13:02 Z khoquennguoiminhthuong Strange Device (APIO19_strange_device) C++14
65 / 100
466 ms 16976 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*b<=2e18)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 4 ms 600 KB Output is correct
3 Correct 4 ms 600 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 5 ms 600 KB Output is correct
17 Correct 43 ms 2492 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 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 1 ms 340 KB Output is correct
5 Correct 281 ms 16760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 415 ms 16860 KB Output is correct
3 Correct 370 ms 16812 KB Output is correct
4 Correct 364 ms 16824 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 415 ms 16860 KB Output is correct
3 Correct 370 ms 16812 KB Output is correct
4 Correct 364 ms 16824 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 380 ms 16748 KB Output is correct
7 Correct 371 ms 16876 KB Output is correct
8 Correct 365 ms 16952 KB Output is correct
9 Correct 392 ms 16800 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 415 ms 16860 KB Output is correct
3 Correct 370 ms 16812 KB Output is correct
4 Correct 364 ms 16824 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 37 ms 2520 KB Output is correct
7 Correct 40 ms 2528 KB Output is correct
8 Correct 37 ms 2484 KB Output is correct
9 Correct 38 ms 2456 KB Output is correct
10 Correct 38 ms 2448 KB Output is correct
11 Correct 38 ms 2512 KB Output is correct
12 Correct 36 ms 2512 KB Output is correct
13 Correct 40 ms 2512 KB Output is correct
14 Correct 37 ms 2520 KB Output is correct
15 Correct 42 ms 2500 KB Output is correct
16 Correct 39 ms 2476 KB Output is correct
17 Correct 38 ms 2528 KB Output is correct
18 Correct 373 ms 16840 KB Output is correct
19 Correct 363 ms 16876 KB Output is correct
20 Correct 400 ms 16796 KB Output is correct
21 Correct 38 ms 2512 KB Output is correct
22 Correct 35 ms 2524 KB Output is correct
23 Correct 122 ms 8608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 40 ms 2512 KB Output is correct
3 Correct 41 ms 2408 KB Output is correct
4 Correct 466 ms 16752 KB Output is correct
5 Correct 39 ms 2512 KB Output is correct
6 Correct 40 ms 2404 KB Output is correct
7 Correct 41 ms 2500 KB Output is correct
8 Correct 41 ms 2512 KB Output is correct
9 Correct 40 ms 2432 KB Output is correct
10 Correct 40 ms 2512 KB Output is correct
11 Correct 41 ms 2412 KB Output is correct
12 Correct 35 ms 2512 KB Output is correct
13 Correct 41 ms 2512 KB Output is correct
14 Correct 412 ms 16848 KB Output is correct
15 Correct 41 ms 2500 KB Output is correct
16 Correct 376 ms 16912 KB Output is correct
17 Correct 383 ms 16976 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 4 ms 600 KB Output is correct
3 Correct 4 ms 600 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 5 ms 600 KB Output is correct
17 Correct 43 ms 2492 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Incorrect 0 ms 212 KB Output isn't correct
21 Halted 0 ms 0 KB -