Submission #982485

# Submission time Handle Problem Language Result Execution time Memory
982485 2024-05-14T09:54:15 Z vjudge1 Strange Device (APIO19_strange_device) C++17
100 / 100
414 ms 53792 KB
#include<bits/stdc++.h>
#define f first
#define s second
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vvi vector<vi>
#define vll vector<ll>
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    ll n,a,b,d;cin>>n>>a>>b;d=a/__gcd(a,b+1);
    vector<pll>rq;
    for(int i=1;i<=n;i++){
        ll l,r;cin>>l>>r;
        ll tl=l/d;tl/=b;
        ll tr=r/d;tr/=b;
        if(tl==tr)rq.pb({l%(d*b),r%(d*b)});
        else if(tl==tr-1)rq.pb({l%(d*b),d*b-1}),rq.pb({0,r%(d*b)});
        else {cout<<d*b;return 0;}
    }sort(rq.begin(),rq.end());ll ans=0,cur=-1;
    for(int i=0;i<rq.size();i++){
        ans+=max(rq[i].s-max(rq[i].f-1,cur),1ll*0);
        cur=max(cur,rq[i].s);
    }cout<<ans;
}

Compilation message

strange_device.cpp: In function 'int main()':
strange_device.cpp:26:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for(int i=0;i<rq.size();i++){
      |                 ~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 4 ms 1116 KB Output is correct
3 Correct 4 ms 1112 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 456 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 456 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 4 ms 1116 KB Output is correct
17 Correct 39 ms 4380 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 456 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 231 ms 29484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 343 ms 35592 KB Output is correct
3 Correct 322 ms 35492 KB Output is correct
4 Correct 308 ms 34848 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 343 ms 35592 KB Output is correct
3 Correct 322 ms 35492 KB Output is correct
4 Correct 308 ms 34848 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 333 ms 35288 KB Output is correct
7 Correct 340 ms 53168 KB Output is correct
8 Correct 328 ms 53172 KB Output is correct
9 Correct 345 ms 53336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 343 ms 35592 KB Output is correct
3 Correct 322 ms 35492 KB Output is correct
4 Correct 308 ms 34848 KB Output is correct
5 Correct 0 ms 448 KB Output is correct
6 Correct 34 ms 4100 KB Output is correct
7 Correct 36 ms 4232 KB Output is correct
8 Correct 33 ms 4000 KB Output is correct
9 Correct 33 ms 4032 KB Output is correct
10 Correct 33 ms 4232 KB Output is correct
11 Correct 35 ms 4100 KB Output is correct
12 Correct 33 ms 4168 KB Output is correct
13 Correct 34 ms 4036 KB Output is correct
14 Correct 38 ms 4136 KB Output is correct
15 Correct 42 ms 4100 KB Output is correct
16 Correct 37 ms 4044 KB Output is correct
17 Correct 39 ms 4048 KB Output is correct
18 Correct 395 ms 34848 KB Output is correct
19 Correct 328 ms 53792 KB Output is correct
20 Correct 364 ms 53280 KB Output is correct
21 Correct 44 ms 5668 KB Output is correct
22 Correct 31 ms 5744 KB Output is correct
23 Correct 103 ms 20308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 39 ms 2520 KB Output is correct
3 Correct 36 ms 2520 KB Output is correct
4 Correct 402 ms 16940 KB Output is correct
5 Correct 37 ms 2520 KB Output is correct
6 Correct 41 ms 2520 KB Output is correct
7 Correct 40 ms 2624 KB Output is correct
8 Correct 39 ms 2880 KB Output is correct
9 Correct 34 ms 2520 KB Output is correct
10 Correct 37 ms 2528 KB Output is correct
11 Correct 39 ms 2596 KB Output is correct
12 Correct 31 ms 2520 KB Output is correct
13 Correct 47 ms 2520 KB Output is correct
14 Correct 372 ms 17332 KB Output is correct
15 Correct 36 ms 2472 KB Output is correct
16 Correct 341 ms 18664 KB Output is correct
17 Correct 332 ms 18052 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 4 ms 1116 KB Output is correct
3 Correct 4 ms 1112 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 456 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 456 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 4 ms 1116 KB Output is correct
17 Correct 39 ms 4380 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 456 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 456 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 512 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 231 ms 29484 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 343 ms 35592 KB Output is correct
31 Correct 322 ms 35492 KB Output is correct
32 Correct 308 ms 34848 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
34 Correct 333 ms 35288 KB Output is correct
35 Correct 340 ms 53168 KB Output is correct
36 Correct 328 ms 53172 KB Output is correct
37 Correct 345 ms 53336 KB Output is correct
38 Correct 0 ms 448 KB Output is correct
39 Correct 34 ms 4100 KB Output is correct
40 Correct 36 ms 4232 KB Output is correct
41 Correct 33 ms 4000 KB Output is correct
42 Correct 33 ms 4032 KB Output is correct
43 Correct 33 ms 4232 KB Output is correct
44 Correct 35 ms 4100 KB Output is correct
45 Correct 33 ms 4168 KB Output is correct
46 Correct 34 ms 4036 KB Output is correct
47 Correct 38 ms 4136 KB Output is correct
48 Correct 42 ms 4100 KB Output is correct
49 Correct 37 ms 4044 KB Output is correct
50 Correct 39 ms 4048 KB Output is correct
51 Correct 395 ms 34848 KB Output is correct
52 Correct 328 ms 53792 KB Output is correct
53 Correct 364 ms 53280 KB Output is correct
54 Correct 44 ms 5668 KB Output is correct
55 Correct 31 ms 5744 KB Output is correct
56 Correct 103 ms 20308 KB Output is correct
57 Correct 0 ms 348 KB Output is correct
58 Correct 39 ms 2520 KB Output is correct
59 Correct 36 ms 2520 KB Output is correct
60 Correct 402 ms 16940 KB Output is correct
61 Correct 37 ms 2520 KB Output is correct
62 Correct 41 ms 2520 KB Output is correct
63 Correct 40 ms 2624 KB Output is correct
64 Correct 39 ms 2880 KB Output is correct
65 Correct 34 ms 2520 KB Output is correct
66 Correct 37 ms 2528 KB Output is correct
67 Correct 39 ms 2596 KB Output is correct
68 Correct 31 ms 2520 KB Output is correct
69 Correct 47 ms 2520 KB Output is correct
70 Correct 372 ms 17332 KB Output is correct
71 Correct 36 ms 2472 KB Output is correct
72 Correct 341 ms 18664 KB Output is correct
73 Correct 332 ms 18052 KB Output is correct
74 Correct 0 ms 348 KB Output is correct
75 Correct 1 ms 452 KB Output is correct
76 Correct 0 ms 348 KB Output is correct
77 Correct 0 ms 348 KB Output is correct
78 Correct 0 ms 348 KB Output is correct
79 Correct 4 ms 1100 KB Output is correct
80 Correct 414 ms 53152 KB Output is correct
81 Correct 404 ms 53232 KB Output is correct
82 Correct 362 ms 53652 KB Output is correct
83 Correct 358 ms 53112 KB Output is correct
84 Correct 355 ms 53652 KB Output is correct
85 Correct 376 ms 53208 KB Output is correct
86 Correct 101 ms 20272 KB Output is correct
87 Correct 0 ms 344 KB Output is correct