# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
153895 | 2019-09-17T11:11:13 Z | DystoriaX | Strange Device (APIO19_strange_device) | C++14 | 637 ms | 17216 KB |
#include <bits/stdc++.h> using namespace std; int n; long long a, b, mx; const long long inf = 2e18; vector<pair<long long, long long> > seg; long long gcd(long long a, long long b){ if(b == 0) return a; return gcd(b, a % b); } int main(){ scanf("%d%lld%lld", &n, &a, &b); mx = a / gcd(a, b + 1); if(inf / mx < b){ mx = 1e18; } else mx *= b; for(int i = 0; i < n; i++){ long long l, r; scanf("%lld%lld", &l, &r); l %= mx, r %= mx; if(r - l + 1 >= mx){ seg.emplace_back(0, mx - 1); } else if (l <= r){ seg.emplace_back(l, r); } else { seg.emplace_back(l, mx - 1); seg.emplace_back(0, r); } } sort(seg.begin(), seg.end()); long long ans = 0, last = 0; for(auto k : seg){ ans += max(0LL, k.second - max(last, k.first) + 1); last = max(last, k.second + 1); } printf("%lld\n", ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 7 ms | 888 KB | Output is correct |
3 | Correct | 8 ms | 760 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Correct | 2 ms | 256 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 256 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 256 KB | Output is correct |
12 | Correct | 2 ms | 256 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 256 KB | Output is correct |
15 | Correct | 2 ms | 256 KB | Output is correct |
16 | Correct | 9 ms | 888 KB | Output is correct |
17 | Correct | 64 ms | 2860 KB | Output is correct |
18 | Correct | 2 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Incorrect | 2 ms | 376 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 3 ms | 376 KB | Output is correct |
3 | Correct | 3 ms | 376 KB | Output is correct |
4 | Correct | 3 ms | 376 KB | Output is correct |
5 | Correct | 430 ms | 17216 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 392 KB | Output is correct |
2 | Correct | 576 ms | 17132 KB | Output is correct |
3 | Correct | 558 ms | 17076 KB | Output is correct |
4 | Correct | 531 ms | 16948 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 392 KB | Output is correct |
2 | Correct | 576 ms | 17132 KB | Output is correct |
3 | Correct | 558 ms | 17076 KB | Output is correct |
4 | Correct | 531 ms | 16948 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 549 ms | 16960 KB | Output is correct |
7 | Correct | 576 ms | 16968 KB | Output is correct |
8 | Correct | 559 ms | 16940 KB | Output is correct |
9 | Correct | 592 ms | 16956 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 392 KB | Output is correct |
2 | Correct | 576 ms | 17132 KB | Output is correct |
3 | Correct | 558 ms | 17076 KB | Output is correct |
4 | Correct | 531 ms | 16948 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 57 ms | 2640 KB | Output is correct |
7 | Correct | 60 ms | 2648 KB | Output is correct |
8 | Correct | 53 ms | 2568 KB | Output is correct |
9 | Correct | 55 ms | 2668 KB | Output is correct |
10 | Correct | 56 ms | 2664 KB | Output is correct |
11 | Correct | 59 ms | 2656 KB | Output is correct |
12 | Correct | 54 ms | 2664 KB | Output is correct |
13 | Correct | 60 ms | 2664 KB | Output is correct |
14 | Correct | 56 ms | 2584 KB | Output is correct |
15 | Correct | 62 ms | 2584 KB | Output is correct |
16 | Correct | 61 ms | 2664 KB | Output is correct |
17 | Correct | 56 ms | 2668 KB | Output is correct |
18 | Correct | 565 ms | 16968 KB | Output is correct |
19 | Correct | 551 ms | 16916 KB | Output is correct |
20 | Correct | 637 ms | 17028 KB | Output is correct |
21 | Correct | 61 ms | 2664 KB | Output is correct |
22 | Correct | 54 ms | 2684 KB | Output is correct |
23 | Correct | 215 ms | 8628 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 62 ms | 2748 KB | Output is correct |
3 | Correct | 62 ms | 2876 KB | Output is correct |
4 | Correct | 618 ms | 17124 KB | Output is correct |
5 | Correct | 58 ms | 2800 KB | Output is correct |
6 | Correct | 59 ms | 2820 KB | Output is correct |
7 | Correct | 58 ms | 2544 KB | Output is correct |
8 | Correct | 63 ms | 2540 KB | Output is correct |
9 | Correct | 60 ms | 2812 KB | Output is correct |
10 | Correct | 59 ms | 2792 KB | Output is correct |
11 | Correct | 61 ms | 2712 KB | Output is correct |
12 | Correct | 53 ms | 2728 KB | Output is correct |
13 | Correct | 61 ms | 2664 KB | Output is correct |
14 | Correct | 617 ms | 16808 KB | Output is correct |
15 | Correct | 60 ms | 2544 KB | Output is correct |
16 | Correct | 565 ms | 16876 KB | Output is correct |
17 | Correct | 552 ms | 16940 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 7 ms | 888 KB | Output is correct |
3 | Correct | 8 ms | 760 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Correct | 2 ms | 256 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 256 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 256 KB | Output is correct |
12 | Correct | 2 ms | 256 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 256 KB | Output is correct |
15 | Correct | 2 ms | 256 KB | Output is correct |
16 | Correct | 9 ms | 888 KB | Output is correct |
17 | Correct | 64 ms | 2860 KB | Output is correct |
18 | Correct | 2 ms | 256 KB | Output is correct |
19 | Correct | 2 ms | 256 KB | Output is correct |
20 | Incorrect | 2 ms | 376 KB | Output isn't correct |
21 | Halted | 0 ms | 0 KB | - |