Submission #252135

# Submission time Handle Problem Language Result Execution time Memory
252135 2020-07-24T09:51:21 Z Sugardorj Strange Device (APIO19_strange_device) C++14
100 / 100
2676 ms 63224 KB
#include <bits/stdc++.h>
using namespace std;
long long i,j,a,b,tt;
long long x,r,m,n,s,t,k,l,y,z;
set <pair<long long,long long>> p,c,d,e;
int main(){
    cin >> n>>a>>b;
    m = a/__gcd(a,b+1);
    if (m >1000000000000000000/b)
        m = 1000000000000000001;
    else m*=b;
    a=m;
    for (i = 0; i<n; i ++){
        cin >>x>>y;
        if (y-x+1>=a){
            cout << a;
            return 0;
        }
        x%=a;
        y%=a;
        if (x <=y){
            p.insert({x,y});
        }
        else {
            p.insert({0,y});
            p.insert({x,a-1});
        }
    }
    t = -1;
    while (p.size()){
        auto u=*p.begin();
        p.erase(*p.begin());
        x=u.first;
        y=u.second;
        t=max(t,x-1);
        s+=max(y-t,0ll);
        t=max(y,t);
    }
    cout <<s;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 24 ms 896 KB Output is correct
3 Correct 25 ms 1016 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 23 ms 896 KB Output is correct
17 Correct 235 ms 6520 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 1492 ms 360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 2377 ms 62916 KB Output is correct
3 Correct 2383 ms 62968 KB Output is correct
4 Correct 2425 ms 62968 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 2377 ms 62916 KB Output is correct
3 Correct 2383 ms 62968 KB Output is correct
4 Correct 2425 ms 62968 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 2405 ms 62960 KB Output is correct
7 Correct 2422 ms 62872 KB Output is correct
8 Correct 2383 ms 62968 KB Output is correct
9 Correct 2472 ms 62920 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 2377 ms 62916 KB Output is correct
3 Correct 2383 ms 62968 KB Output is correct
4 Correct 2425 ms 62968 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 232 ms 6520 KB Output is correct
7 Correct 234 ms 6648 KB Output is correct
8 Correct 237 ms 6524 KB Output is correct
9 Correct 246 ms 6532 KB Output is correct
10 Correct 247 ms 6520 KB Output is correct
11 Correct 236 ms 6648 KB Output is correct
12 Correct 230 ms 6520 KB Output is correct
13 Correct 241 ms 6520 KB Output is correct
14 Correct 232 ms 6648 KB Output is correct
15 Correct 242 ms 6520 KB Output is correct
16 Correct 251 ms 6520 KB Output is correct
17 Correct 244 ms 6596 KB Output is correct
18 Correct 2380 ms 63048 KB Output is correct
19 Correct 2429 ms 63212 KB Output is correct
20 Correct 2515 ms 63224 KB Output is correct
21 Correct 252 ms 6648 KB Output is correct
22 Correct 241 ms 6520 KB Output is correct
23 Correct 702 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 253 ms 6512 KB Output is correct
3 Correct 238 ms 6520 KB Output is correct
4 Correct 2465 ms 62872 KB Output is correct
5 Correct 243 ms 6520 KB Output is correct
6 Correct 240 ms 6520 KB Output is correct
7 Correct 251 ms 6776 KB Output is correct
8 Correct 240 ms 6504 KB Output is correct
9 Correct 238 ms 6520 KB Output is correct
10 Correct 249 ms 6652 KB Output is correct
11 Correct 250 ms 6520 KB Output is correct
12 Correct 241 ms 6620 KB Output is correct
13 Correct 252 ms 6652 KB Output is correct
14 Correct 2573 ms 63024 KB Output is correct
15 Correct 236 ms 6508 KB Output is correct
16 Correct 2368 ms 62968 KB Output is correct
17 Correct 2438 ms 63168 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 24 ms 896 KB Output is correct
3 Correct 25 ms 1016 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 23 ms 896 KB Output is correct
17 Correct 235 ms 6520 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 0 ms 256 KB Output is correct
20 Correct 1 ms 256 KB Output is correct
21 Correct 2 ms 256 KB Output is correct
22 Correct 0 ms 256 KB Output is correct
23 Correct 0 ms 256 KB Output is correct
24 Correct 0 ms 256 KB Output is correct
25 Correct 3 ms 384 KB Output is correct
26 Correct 3 ms 384 KB Output is correct
27 Correct 3 ms 384 KB Output is correct
28 Correct 1492 ms 360 KB Output is correct
29 Correct 0 ms 256 KB Output is correct
30 Correct 2377 ms 62916 KB Output is correct
31 Correct 2383 ms 62968 KB Output is correct
32 Correct 2425 ms 62968 KB Output is correct
33 Correct 0 ms 256 KB Output is correct
34 Correct 2405 ms 62960 KB Output is correct
35 Correct 2422 ms 62872 KB Output is correct
36 Correct 2383 ms 62968 KB Output is correct
37 Correct 2472 ms 62920 KB Output is correct
38 Correct 0 ms 256 KB Output is correct
39 Correct 232 ms 6520 KB Output is correct
40 Correct 234 ms 6648 KB Output is correct
41 Correct 237 ms 6524 KB Output is correct
42 Correct 246 ms 6532 KB Output is correct
43 Correct 247 ms 6520 KB Output is correct
44 Correct 236 ms 6648 KB Output is correct
45 Correct 230 ms 6520 KB Output is correct
46 Correct 241 ms 6520 KB Output is correct
47 Correct 232 ms 6648 KB Output is correct
48 Correct 242 ms 6520 KB Output is correct
49 Correct 251 ms 6520 KB Output is correct
50 Correct 244 ms 6596 KB Output is correct
51 Correct 2380 ms 63048 KB Output is correct
52 Correct 2429 ms 63212 KB Output is correct
53 Correct 2515 ms 63224 KB Output is correct
54 Correct 252 ms 6648 KB Output is correct
55 Correct 241 ms 6520 KB Output is correct
56 Correct 702 ms 376 KB Output is correct
57 Correct 0 ms 256 KB Output is correct
58 Correct 253 ms 6512 KB Output is correct
59 Correct 238 ms 6520 KB Output is correct
60 Correct 2465 ms 62872 KB Output is correct
61 Correct 243 ms 6520 KB Output is correct
62 Correct 240 ms 6520 KB Output is correct
63 Correct 251 ms 6776 KB Output is correct
64 Correct 240 ms 6504 KB Output is correct
65 Correct 238 ms 6520 KB Output is correct
66 Correct 249 ms 6652 KB Output is correct
67 Correct 250 ms 6520 KB Output is correct
68 Correct 241 ms 6620 KB Output is correct
69 Correct 252 ms 6652 KB Output is correct
70 Correct 2573 ms 63024 KB Output is correct
71 Correct 236 ms 6508 KB Output is correct
72 Correct 2368 ms 62968 KB Output is correct
73 Correct 2438 ms 63168 KB Output is correct
74 Correct 1 ms 256 KB Output is correct
75 Correct 1 ms 384 KB Output is correct
76 Correct 0 ms 256 KB Output is correct
77 Correct 1 ms 256 KB Output is correct
78 Correct 1 ms 256 KB Output is correct
79 Correct 24 ms 896 KB Output is correct
80 Correct 2465 ms 62968 KB Output is correct
81 Correct 2480 ms 63120 KB Output is correct
82 Correct 2551 ms 63168 KB Output is correct
83 Correct 2467 ms 62980 KB Output is correct
84 Correct 2676 ms 62896 KB Output is correct
85 Correct 2453 ms 63044 KB Output is correct
86 Correct 688 ms 360 KB Output is correct
87 Correct 0 ms 256 KB Output is correct