# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
254847 | 2020-07-30T17:48:27 Z | Lawliet | Strange Device (APIO19_strange_device) | C++17 | 623 ms | 53480 KB |
#include <bits/stdc++.h> using namespace std; typedef long long int lli; typedef pair<lli,lli> pll; lli n, A, B; vector<pll> sweep; vector<pll> merged; int main() { scanf("%lld %lld %lld",&n,&A,&B); lli cycleSize = A/__gcd( A , B + 1 ); lli periodSize = 1000000000000000000LL; if( cycleSize <= periodSize/B ) periodSize = cycleSize*B; for(int i = 1 ; i <= n ; i++) { lli L, R; scanf("%lld %lld",&L,&R); if( R - L + 1 >= periodSize ) { printf("%lld\n",periodSize); return 0; } L %= periodSize; R %= periodSize; if( L <= R ) sweep.push_back( { L , R } ); else { sweep.push_back( { 0 , R } ); sweep.push_back( { L , periodSize - 1 } ); } } sort( sweep.begin() , sweep.end() ); lli ans = 0; lli last = -1; for(int i = 0 ; i < (int)sweep.size() ; i++) { last = max( last , sweep[i].first - 1 ); if( last <= sweep[i].second ) ans += sweep[i].second - last; last = max( last , sweep[i].second ); } printf("%lld\n",ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 6 ms | 1152 KB | Output is correct |
3 | Correct | 10 ms | 1024 KB | Output is correct |
4 | Correct | 1 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 | 0 ms | 256 KB | Output is correct |
9 | Correct | 1 ms | 256 KB | Output is correct |
10 | Correct | 1 ms | 256 KB | Output is correct |
11 | Correct | 1 ms | 256 KB | Output is correct |
12 | Correct | 0 ms | 256 KB | Output is correct |
13 | Correct | 0 ms | 256 KB | Output is correct |
14 | Correct | 0 ms | 256 KB | Output is correct |
15 | Correct | 0 ms | 256 KB | Output is correct |
16 | Correct | 6 ms | 1024 KB | Output is correct |
17 | Correct | 59 ms | 5732 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 | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 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 | 1 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 448 ms | 41428 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 522 ms | 17564 KB | Output is correct |
3 | Correct | 513 ms | 17616 KB | Output is correct |
4 | Correct | 520 ms | 17596 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 522 ms | 17564 KB | Output is correct |
3 | Correct | 513 ms | 17616 KB | Output is correct |
4 | Correct | 520 ms | 17596 KB | Output is correct |
5 | Correct | 0 ms | 256 KB | Output is correct |
6 | Correct | 504 ms | 17516 KB | Output is correct |
7 | Correct | 530 ms | 17616 KB | Output is correct |
8 | Correct | 539 ms | 17488 KB | Output is correct |
9 | Correct | 565 ms | 17488 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 522 ms | 17564 KB | Output is correct |
3 | Correct | 513 ms | 17616 KB | Output is correct |
4 | Correct | 520 ms | 17596 KB | Output is correct |
5 | Correct | 0 ms | 256 KB | Output is correct |
6 | Correct | 56 ms | 4204 KB | Output is correct |
7 | Correct | 54 ms | 4204 KB | Output is correct |
8 | Correct | 60 ms | 4204 KB | Output is correct |
9 | Correct | 52 ms | 4204 KB | Output is correct |
10 | Correct | 73 ms | 4204 KB | Output is correct |
11 | Correct | 58 ms | 4204 KB | Output is correct |
12 | Correct | 51 ms | 4280 KB | Output is correct |
13 | Correct | 54 ms | 4204 KB | Output is correct |
14 | Correct | 52 ms | 4204 KB | Output is correct |
15 | Correct | 57 ms | 4204 KB | Output is correct |
16 | Correct | 62 ms | 5736 KB | Output is correct |
17 | Correct | 56 ms | 5740 KB | Output is correct |
18 | Correct | 552 ms | 53308 KB | Output is correct |
19 | Correct | 521 ms | 53476 KB | Output is correct |
20 | Correct | 593 ms | 53308 KB | Output is correct |
21 | Correct | 56 ms | 5736 KB | Output is correct |
22 | Correct | 50 ms | 5760 KB | Output is correct |
23 | Correct | 204 ms | 18524 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Correct | 56 ms | 4204 KB | Output is correct |
3 | Correct | 54 ms | 4204 KB | Output is correct |
4 | Correct | 602 ms | 17360 KB | Output is correct |
5 | Correct | 54 ms | 4332 KB | Output is correct |
6 | Correct | 55 ms | 4324 KB | Output is correct |
7 | Correct | 56 ms | 4328 KB | Output is correct |
8 | Correct | 59 ms | 4584 KB | Output is correct |
9 | Correct | 55 ms | 4836 KB | Output is correct |
10 | Correct | 55 ms | 4964 KB | Output is correct |
11 | Correct | 58 ms | 4892 KB | Output is correct |
12 | Correct | 49 ms | 5224 KB | Output is correct |
13 | Correct | 56 ms | 5224 KB | Output is correct |
14 | Correct | 574 ms | 17460 KB | Output is correct |
15 | Correct | 56 ms | 5732 KB | Output is correct |
16 | Correct | 539 ms | 53452 KB | Output is correct |
17 | Correct | 540 ms | 53308 KB | Output is correct |
18 | Correct | 1 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 6 ms | 1152 KB | Output is correct |
3 | Correct | 10 ms | 1024 KB | Output is correct |
4 | Correct | 1 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 | 0 ms | 256 KB | Output is correct |
9 | Correct | 1 ms | 256 KB | Output is correct |
10 | Correct | 1 ms | 256 KB | Output is correct |
11 | Correct | 1 ms | 256 KB | Output is correct |
12 | Correct | 0 ms | 256 KB | Output is correct |
13 | Correct | 0 ms | 256 KB | Output is correct |
14 | Correct | 0 ms | 256 KB | Output is correct |
15 | Correct | 0 ms | 256 KB | Output is correct |
16 | Correct | 6 ms | 1024 KB | Output is correct |
17 | Correct | 59 ms | 5732 KB | Output is correct |
18 | Correct | 0 ms | 256 KB | Output is correct |
19 | Correct | 0 ms | 256 KB | Output is correct |
20 | Correct | 0 ms | 256 KB | Output is correct |
21 | Correct | 0 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 | 1 ms | 384 KB | Output is correct |
26 | Correct | 1 ms | 384 KB | Output is correct |
27 | Correct | 1 ms | 384 KB | Output is correct |
28 | Correct | 448 ms | 41428 KB | Output is correct |
29 | Correct | 0 ms | 256 KB | Output is correct |
30 | Correct | 522 ms | 17564 KB | Output is correct |
31 | Correct | 513 ms | 17616 KB | Output is correct |
32 | Correct | 520 ms | 17596 KB | Output is correct |
33 | Correct | 0 ms | 256 KB | Output is correct |
34 | Correct | 504 ms | 17516 KB | Output is correct |
35 | Correct | 530 ms | 17616 KB | Output is correct |
36 | Correct | 539 ms | 17488 KB | Output is correct |
37 | Correct | 565 ms | 17488 KB | Output is correct |
38 | Correct | 0 ms | 256 KB | Output is correct |
39 | Correct | 56 ms | 4204 KB | Output is correct |
40 | Correct | 54 ms | 4204 KB | Output is correct |
41 | Correct | 60 ms | 4204 KB | Output is correct |
42 | Correct | 52 ms | 4204 KB | Output is correct |
43 | Correct | 73 ms | 4204 KB | Output is correct |
44 | Correct | 58 ms | 4204 KB | Output is correct |
45 | Correct | 51 ms | 4280 KB | Output is correct |
46 | Correct | 54 ms | 4204 KB | Output is correct |
47 | Correct | 52 ms | 4204 KB | Output is correct |
48 | Correct | 57 ms | 4204 KB | Output is correct |
49 | Correct | 62 ms | 5736 KB | Output is correct |
50 | Correct | 56 ms | 5740 KB | Output is correct |
51 | Correct | 552 ms | 53308 KB | Output is correct |
52 | Correct | 521 ms | 53476 KB | Output is correct |
53 | Correct | 593 ms | 53308 KB | Output is correct |
54 | Correct | 56 ms | 5736 KB | Output is correct |
55 | Correct | 50 ms | 5760 KB | Output is correct |
56 | Correct | 204 ms | 18524 KB | Output is correct |
57 | Correct | 1 ms | 256 KB | Output is correct |
58 | Correct | 56 ms | 4204 KB | Output is correct |
59 | Correct | 54 ms | 4204 KB | Output is correct |
60 | Correct | 602 ms | 17360 KB | Output is correct |
61 | Correct | 54 ms | 4332 KB | Output is correct |
62 | Correct | 55 ms | 4324 KB | Output is correct |
63 | Correct | 56 ms | 4328 KB | Output is correct |
64 | Correct | 59 ms | 4584 KB | Output is correct |
65 | Correct | 55 ms | 4836 KB | Output is correct |
66 | Correct | 55 ms | 4964 KB | Output is correct |
67 | Correct | 58 ms | 4892 KB | Output is correct |
68 | Correct | 49 ms | 5224 KB | Output is correct |
69 | Correct | 56 ms | 5224 KB | Output is correct |
70 | Correct | 574 ms | 17460 KB | Output is correct |
71 | Correct | 56 ms | 5732 KB | Output is correct |
72 | Correct | 539 ms | 53452 KB | Output is correct |
73 | Correct | 540 ms | 53308 KB | Output is correct |
74 | Correct | 1 ms | 256 KB | Output is correct |
75 | Correct | 1 ms | 256 KB | Output is correct |
76 | Correct | 1 ms | 256 KB | Output is correct |
77 | Correct | 0 ms | 256 KB | Output is correct |
78 | Correct | 1 ms | 256 KB | Output is correct |
79 | Correct | 10 ms | 1152 KB | Output is correct |
80 | Correct | 623 ms | 53420 KB | Output is correct |
81 | Correct | 598 ms | 53292 KB | Output is correct |
82 | Correct | 558 ms | 53308 KB | Output is correct |
83 | Correct | 588 ms | 53480 KB | Output is correct |
84 | Correct | 576 ms | 53420 KB | Output is correct |
85 | Correct | 565 ms | 53236 KB | Output is correct |
86 | Correct | 206 ms | 18524 KB | Output is correct |
87 | Correct | 1 ms | 256 KB | Output is correct |