# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
200513 | 2020-02-07T03:19:08 Z | HellAngel | Strange Device (APIO19_strange_device) | C++14 | 757 ms | 33844 KB |
#include <bits/stdc++.h> #define int long long const int inf = (int)1e18 + 69; using namespace std; const int maxn = 1e6 + 7; int n, l[maxn], r[maxn], a, b, sum = 0, IT[4 * maxn]; vector<pair<int, int>> vt; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); if(fopen("test.inp", "r")) freopen("test.inp", "r", stdin), freopen("test.out", "w", stdout); cin >> n >> a >> b; for(int i = 1; i <= n; i++) cin >> l[i] >> r[i], sum += r[i] - l[i] + 1; int Dist = a / __gcd(a, b + 1); if(inf / Dist < b) return cout << sum, 0; Dist *= b; /// tối đa có dist giá trị for(int i = 1; i <= n; i++) { int gau = l[i] % Dist; int meo = r[i] % Dist; if(r[i] - l[i] + 1 >= Dist) return cout << Dist << '\n', 0; else { if(gau <= meo) { vt.push_back({gau, meo}); } else { vt.push_back({gau, Dist - 1}); vt.push_back({0, meo}); } } } sort(vt.begin(),vt.end()); assert(vt.size() != 0); int ans1 = vt[0].second - vt[0].first + 1, curl1 = vt[0].second + 1; for(int i = 1; i < vt.size(); i++) { if(vt[i].second >= curl1) { ans1 += vt[i].second - max(curl1, vt[i].first) + 1; curl1 = vt[i].second + 1; } } cout << ans1; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 10 ms | 888 KB | Output is correct |
3 | Correct | 11 ms | 888 KB | Output is correct |
4 | Correct | 5 ms | 376 KB | Output is correct |
5 | Correct | 5 ms | 504 KB | Output is correct |
6 | Correct | 6 ms | 376 KB | Output is correct |
7 | Correct | 5 ms | 376 KB | Output is correct |
8 | Correct | 5 ms | 376 KB | Output is correct |
9 | Correct | 5 ms | 376 KB | Output is correct |
10 | Correct | 9 ms | 376 KB | Output is correct |
11 | Correct | 5 ms | 376 KB | Output is correct |
12 | Correct | 5 ms | 376 KB | Output is correct |
13 | Correct | 5 ms | 376 KB | Output is correct |
14 | Correct | 5 ms | 348 KB | Output is correct |
15 | Correct | 5 ms | 376 KB | Output is correct |
16 | Correct | 10 ms | 1272 KB | Output is correct |
17 | Correct | 65 ms | 7768 KB | Output is correct |
18 | Correct | 5 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
3 | Correct | 5 ms | 376 KB | Output is correct |
4 | Correct | 15 ms | 504 KB | Output is correct |
5 | Correct | 5 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 380 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
3 | Correct | 5 ms | 504 KB | Output is correct |
4 | Correct | 5 ms | 376 KB | Output is correct |
5 | Correct | 390 ms | 33168 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 372 KB | Output is correct |
2 | Correct | 543 ms | 32596 KB | Output is correct |
3 | Correct | 545 ms | 33752 KB | Output is correct |
4 | Correct | 531 ms | 33844 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 372 KB | Output is correct |
2 | Correct | 543 ms | 32596 KB | Output is correct |
3 | Correct | 545 ms | 33752 KB | Output is correct |
4 | Correct | 531 ms | 33844 KB | Output is correct |
5 | Correct | 5 ms | 376 KB | Output is correct |
6 | Correct | 575 ms | 33748 KB | Output is correct |
7 | Correct | 558 ms | 33748 KB | Output is correct |
8 | Correct | 551 ms | 33620 KB | Output is correct |
9 | Correct | 588 ms | 33512 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 372 KB | Output is correct |
2 | Correct | 543 ms | 32596 KB | Output is correct |
3 | Correct | 545 ms | 33752 KB | Output is correct |
4 | Correct | 531 ms | 33844 KB | Output is correct |
5 | Correct | 5 ms | 376 KB | Output is correct |
6 | Correct | 61 ms | 7804 KB | Output is correct |
7 | Correct | 62 ms | 7792 KB | Output is correct |
8 | Correct | 61 ms | 7792 KB | Output is correct |
9 | Correct | 59 ms | 7792 KB | Output is correct |
10 | Correct | 59 ms | 7864 KB | Output is correct |
11 | Correct | 65 ms | 7792 KB | Output is correct |
12 | Correct | 58 ms | 7792 KB | Output is correct |
13 | Correct | 63 ms | 7792 KB | Output is correct |
14 | Correct | 61 ms | 7792 KB | Output is correct |
15 | Correct | 64 ms | 7788 KB | Output is correct |
16 | Correct | 75 ms | 7916 KB | Output is correct |
17 | Correct | 62 ms | 7792 KB | Output is correct |
18 | Correct | 545 ms | 33620 KB | Output is correct |
19 | Correct | 532 ms | 33368 KB | Output is correct |
20 | Correct | 612 ms | 33492 KB | Output is correct |
21 | Correct | 64 ms | 7788 KB | Output is correct |
22 | Correct | 57 ms | 7792 KB | Output is correct |
23 | Correct | 182 ms | 26552 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 68 ms | 4080 KB | Output is correct |
3 | Correct | 62 ms | 4076 KB | Output is correct |
4 | Correct | 607 ms | 32500 KB | Output is correct |
5 | Correct | 62 ms | 4204 KB | Output is correct |
6 | Correct | 69 ms | 4076 KB | Output is correct |
7 | Correct | 60 ms | 4080 KB | Output is correct |
8 | Correct | 65 ms | 4208 KB | Output is correct |
9 | Correct | 61 ms | 4056 KB | Output is correct |
10 | Correct | 62 ms | 4204 KB | Output is correct |
11 | Correct | 61 ms | 4076 KB | Output is correct |
12 | Correct | 57 ms | 4080 KB | Output is correct |
13 | Correct | 64 ms | 4080 KB | Output is correct |
14 | Correct | 575 ms | 32724 KB | Output is correct |
15 | Correct | 63 ms | 4072 KB | Output is correct |
16 | Correct | 549 ms | 32600 KB | Output is correct |
17 | Correct | 757 ms | 32596 KB | Output is correct |
18 | Correct | 5 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 10 ms | 888 KB | Output is correct |
3 | Correct | 11 ms | 888 KB | Output is correct |
4 | Correct | 5 ms | 376 KB | Output is correct |
5 | Correct | 5 ms | 504 KB | Output is correct |
6 | Correct | 6 ms | 376 KB | Output is correct |
7 | Correct | 5 ms | 376 KB | Output is correct |
8 | Correct | 5 ms | 376 KB | Output is correct |
9 | Correct | 5 ms | 376 KB | Output is correct |
10 | Correct | 9 ms | 376 KB | Output is correct |
11 | Correct | 5 ms | 376 KB | Output is correct |
12 | Correct | 5 ms | 376 KB | Output is correct |
13 | Correct | 5 ms | 376 KB | Output is correct |
14 | Correct | 5 ms | 348 KB | Output is correct |
15 | Correct | 5 ms | 376 KB | Output is correct |
16 | Correct | 10 ms | 1272 KB | Output is correct |
17 | Correct | 65 ms | 7768 KB | Output is correct |
18 | Correct | 5 ms | 376 KB | Output is correct |
19 | Correct | 5 ms | 376 KB | Output is correct |
20 | Correct | 5 ms | 376 KB | Output is correct |
21 | Correct | 5 ms | 376 KB | Output is correct |
22 | Correct | 15 ms | 504 KB | Output is correct |
23 | Correct | 5 ms | 376 KB | Output is correct |
24 | Correct | 5 ms | 380 KB | Output is correct |
25 | Correct | 5 ms | 376 KB | Output is correct |
26 | Correct | 5 ms | 504 KB | Output is correct |
27 | Correct | 5 ms | 376 KB | Output is correct |
28 | Correct | 390 ms | 33168 KB | Output is correct |
29 | Correct | 5 ms | 372 KB | Output is correct |
30 | Correct | 543 ms | 32596 KB | Output is correct |
31 | Correct | 545 ms | 33752 KB | Output is correct |
32 | Correct | 531 ms | 33844 KB | Output is correct |
33 | Correct | 5 ms | 376 KB | Output is correct |
34 | Correct | 575 ms | 33748 KB | Output is correct |
35 | Correct | 558 ms | 33748 KB | Output is correct |
36 | Correct | 551 ms | 33620 KB | Output is correct |
37 | Correct | 588 ms | 33512 KB | Output is correct |
38 | Correct | 5 ms | 376 KB | Output is correct |
39 | Correct | 61 ms | 7804 KB | Output is correct |
40 | Correct | 62 ms | 7792 KB | Output is correct |
41 | Correct | 61 ms | 7792 KB | Output is correct |
42 | Correct | 59 ms | 7792 KB | Output is correct |
43 | Correct | 59 ms | 7864 KB | Output is correct |
44 | Correct | 65 ms | 7792 KB | Output is correct |
45 | Correct | 58 ms | 7792 KB | Output is correct |
46 | Correct | 63 ms | 7792 KB | Output is correct |
47 | Correct | 61 ms | 7792 KB | Output is correct |
48 | Correct | 64 ms | 7788 KB | Output is correct |
49 | Correct | 75 ms | 7916 KB | Output is correct |
50 | Correct | 62 ms | 7792 KB | Output is correct |
51 | Correct | 545 ms | 33620 KB | Output is correct |
52 | Correct | 532 ms | 33368 KB | Output is correct |
53 | Correct | 612 ms | 33492 KB | Output is correct |
54 | Correct | 64 ms | 7788 KB | Output is correct |
55 | Correct | 57 ms | 7792 KB | Output is correct |
56 | Correct | 182 ms | 26552 KB | Output is correct |
57 | Correct | 5 ms | 376 KB | Output is correct |
58 | Correct | 68 ms | 4080 KB | Output is correct |
59 | Correct | 62 ms | 4076 KB | Output is correct |
60 | Correct | 607 ms | 32500 KB | Output is correct |
61 | Correct | 62 ms | 4204 KB | Output is correct |
62 | Correct | 69 ms | 4076 KB | Output is correct |
63 | Correct | 60 ms | 4080 KB | Output is correct |
64 | Correct | 65 ms | 4208 KB | Output is correct |
65 | Correct | 61 ms | 4056 KB | Output is correct |
66 | Correct | 62 ms | 4204 KB | Output is correct |
67 | Correct | 61 ms | 4076 KB | Output is correct |
68 | Correct | 57 ms | 4080 KB | Output is correct |
69 | Correct | 64 ms | 4080 KB | Output is correct |
70 | Correct | 575 ms | 32724 KB | Output is correct |
71 | Correct | 63 ms | 4072 KB | Output is correct |
72 | Correct | 549 ms | 32600 KB | Output is correct |
73 | Correct | 757 ms | 32596 KB | Output is correct |
74 | Correct | 5 ms | 376 KB | Output is correct |
75 | Correct | 5 ms | 376 KB | Output is correct |
76 | Correct | 5 ms | 376 KB | Output is correct |
77 | Correct | 5 ms | 376 KB | Output is correct |
78 | Correct | 5 ms | 380 KB | Output is correct |
79 | Correct | 10 ms | 1272 KB | Output is correct |
80 | Correct | 615 ms | 33364 KB | Output is correct |
81 | Correct | 642 ms | 33364 KB | Output is correct |
82 | Correct | 592 ms | 33368 KB | Output is correct |
83 | Correct | 597 ms | 33492 KB | Output is correct |
84 | Correct | 598 ms | 33364 KB | Output is correct |
85 | Correct | 596 ms | 33112 KB | Output is correct |
86 | Correct | 175 ms | 21600 KB | Output is correct |
87 | Correct | 5 ms | 376 KB | Output is correct |