Submission #1100789

# Submission time Handle Problem Language Result Execution time Memory
1100789 2024-10-14T18:09:32 Z imarn Strange Device (APIO19_strange_device) C++14
100 / 100
360 ms 51700 KB
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define plx pair<ll,int>
#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;ll a,b;cin>>n>>a>>b;
    a/=__gcd(a,b+1);
    vector<pll>vec;
    ll t =a*b;
    for(int i=0;i<n;i++){
        ll l,r;cin>>l>>r;
        if(l/t==r/t){
            vec.pb({l%t,r%t});
        }
        if(l/t+1==r/t){
            vec.pb({l%t,t-1});
            vec.pb({0,r%t});
        }
        if(r/t>=l/t+2){
            cout<<t;return 0;
        }
    }ll rs=0;sort(all(vec));
    ll cur=-1;
    for(int i=0;i<vec.size();i++){
        cur = max(cur,vec[i].f);
        rs += max(1ll*0,vec[i].s-cur+1);
        cur = max(cur,vec[i].s+1);
    }cout<<rs;
}

Compilation message

strange_device.cpp: In function 'int main()':
strange_device.cpp:34: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]
   34 |     for(int i=0;i<vec.size();i++){
      |                 ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 3 ms 848 KB Output is correct
3 Correct 3 ms 848 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 456 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 0 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 508 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 3 ms 724 KB Output is correct
17 Correct 34 ms 5660 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 504 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 184 ms 18900 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 245 ms 18880 KB Output is correct
3 Correct 271 ms 18912 KB Output is correct
4 Correct 265 ms 49256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 245 ms 18880 KB Output is correct
3 Correct 271 ms 18912 KB Output is correct
4 Correct 265 ms 49256 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 267 ms 35516 KB Output is correct
7 Correct 273 ms 41600 KB Output is correct
8 Correct 265 ms 51200 KB Output is correct
9 Correct 360 ms 45344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 245 ms 18880 KB Output is correct
3 Correct 271 ms 18912 KB Output is correct
4 Correct 265 ms 49256 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 28 ms 6228 KB Output is correct
7 Correct 31 ms 6348 KB Output is correct
8 Correct 30 ms 6224 KB Output is correct
9 Correct 36 ms 6212 KB Output is correct
10 Correct 28 ms 6108 KB Output is correct
11 Correct 27 ms 6348 KB Output is correct
12 Correct 29 ms 6084 KB Output is correct
13 Correct 33 ms 6360 KB Output is correct
14 Correct 29 ms 6092 KB Output is correct
15 Correct 30 ms 6344 KB Output is correct
16 Correct 28 ms 6348 KB Output is correct
17 Correct 32 ms 5580 KB Output is correct
18 Correct 262 ms 49204 KB Output is correct
19 Correct 267 ms 44820 KB Output is correct
20 Correct 296 ms 45480 KB Output is correct
21 Correct 31 ms 5836 KB Output is correct
22 Correct 28 ms 6092 KB Output is correct
23 Correct 87 ms 19680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 29 ms 6092 KB Output is correct
3 Correct 29 ms 5316 KB Output is correct
4 Correct 318 ms 18864 KB Output is correct
5 Correct 29 ms 6344 KB Output is correct
6 Correct 30 ms 6260 KB Output is correct
7 Correct 29 ms 5836 KB Output is correct
8 Correct 29 ms 5748 KB Output is correct
9 Correct 28 ms 5572 KB Output is correct
10 Correct 38 ms 6180 KB Output is correct
11 Correct 29 ms 5836 KB Output is correct
12 Correct 26 ms 6300 KB Output is correct
13 Correct 29 ms 6208 KB Output is correct
14 Correct 285 ms 48932 KB Output is correct
15 Correct 28 ms 6344 KB Output is correct
16 Correct 254 ms 45184 KB Output is correct
17 Correct 246 ms 37808 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 3 ms 848 KB Output is correct
3 Correct 3 ms 848 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 456 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 0 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 508 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 3 ms 724 KB Output is correct
17 Correct 34 ms 5660 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 0 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 504 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 468 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 184 ms 18900 KB Output is correct
29 Correct 0 ms 336 KB Output is correct
30 Correct 245 ms 18880 KB Output is correct
31 Correct 271 ms 18912 KB Output is correct
32 Correct 265 ms 49256 KB Output is correct
33 Correct 1 ms 336 KB Output is correct
34 Correct 267 ms 35516 KB Output is correct
35 Correct 273 ms 41600 KB Output is correct
36 Correct 265 ms 51200 KB Output is correct
37 Correct 360 ms 45344 KB Output is correct
38 Correct 1 ms 336 KB Output is correct
39 Correct 28 ms 6228 KB Output is correct
40 Correct 31 ms 6348 KB Output is correct
41 Correct 30 ms 6224 KB Output is correct
42 Correct 36 ms 6212 KB Output is correct
43 Correct 28 ms 6108 KB Output is correct
44 Correct 27 ms 6348 KB Output is correct
45 Correct 29 ms 6084 KB Output is correct
46 Correct 33 ms 6360 KB Output is correct
47 Correct 29 ms 6092 KB Output is correct
48 Correct 30 ms 6344 KB Output is correct
49 Correct 28 ms 6348 KB Output is correct
50 Correct 32 ms 5580 KB Output is correct
51 Correct 262 ms 49204 KB Output is correct
52 Correct 267 ms 44820 KB Output is correct
53 Correct 296 ms 45480 KB Output is correct
54 Correct 31 ms 5836 KB Output is correct
55 Correct 28 ms 6092 KB Output is correct
56 Correct 87 ms 19680 KB Output is correct
57 Correct 1 ms 336 KB Output is correct
58 Correct 29 ms 6092 KB Output is correct
59 Correct 29 ms 5316 KB Output is correct
60 Correct 318 ms 18864 KB Output is correct
61 Correct 29 ms 6344 KB Output is correct
62 Correct 30 ms 6260 KB Output is correct
63 Correct 29 ms 5836 KB Output is correct
64 Correct 29 ms 5748 KB Output is correct
65 Correct 28 ms 5572 KB Output is correct
66 Correct 38 ms 6180 KB Output is correct
67 Correct 29 ms 5836 KB Output is correct
68 Correct 26 ms 6300 KB Output is correct
69 Correct 29 ms 6208 KB Output is correct
70 Correct 285 ms 48932 KB Output is correct
71 Correct 28 ms 6344 KB Output is correct
72 Correct 254 ms 45184 KB Output is correct
73 Correct 246 ms 37808 KB Output is correct
74 Correct 1 ms 336 KB Output is correct
75 Correct 1 ms 336 KB Output is correct
76 Correct 1 ms 336 KB Output is correct
77 Correct 1 ms 336 KB Output is correct
78 Correct 1 ms 336 KB Output is correct
79 Correct 3 ms 1272 KB Output is correct
80 Correct 290 ms 50316 KB Output is correct
81 Correct 307 ms 45220 KB Output is correct
82 Correct 305 ms 49324 KB Output is correct
83 Correct 291 ms 46384 KB Output is correct
84 Correct 307 ms 51464 KB Output is correct
85 Correct 308 ms 51700 KB Output is correct
86 Correct 98 ms 20156 KB Output is correct
87 Correct 1 ms 336 KB Output is correct