# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
171729 | 2019-12-30T08:31:39 Z | Sensei | Strange Device (APIO19_strange_device) | C++17 | 660 ms | 46388 KB |
/* DATE: 2019-12-30 11:10:15 NAME: PROBLEM: APIO19_strange_device */ #include <bits/stdc++.h> using namespace std; const int MAXN = 1e6; const long long LLINF = 1e18 + 100; class Segment { public: long long l, r; Segment() {} Segment(long long x, long long y) { l = x; r = y; } }; long long f(long long x, long long y) { if (x / __gcd(x, y) > LLINF / y) { return LLINF; } return x * y; } int main() { int n; cin >> n; long long A, B; cin >> A >> B; long long C = f(A, B); vector<Segment> segments; for (int i = 1; i <= n; i++) { Segment segment; scanf("%lld %lld", &segment.l, &segment.r); segment.l %= C; segment.r %= C; if (segment.l <= segment.r) { segments.push_back(segment); } else { segments.push_back(Segment(0, segment.r)); segments.push_back(Segment(segment.l, C - 1)); } } sort(segments.begin(), segments.end(), [](Segment x, Segment y) { if (x.l == y.l) { return x.r < y.r; } return x.l < y.l; }); long long lastr = -1; long long ans = 0; for (int i = 0; i < segments.size(); i++) { if (segments[i].l > lastr) { lastr = segments[i].l - 1; } if (segments[i].r > lastr) { ans += segments[i].r - lastr; lastr = segments[i].r; } } cout << ans << "\n"; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 8 ms | 888 KB | Output is correct |
3 | Correct | 8 ms | 1148 KB | Output is correct |
4 | Incorrect | 2 ms | 376 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 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 | 380 KB | Output is correct |
2 | Correct | 3 ms | 376 KB | Output is correct |
3 | Correct | 3 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 454 ms | 41248 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 598 ms | 36392 KB | Output is correct |
3 | Incorrect | 593 ms | 33580 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 598 ms | 36392 KB | Output is correct |
3 | Incorrect | 593 ms | 33580 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 598 ms | 36392 KB | Output is correct |
3 | Incorrect | 593 ms | 33580 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 63 ms | 5228 KB | Output is correct |
3 | Correct | 62 ms | 5732 KB | Output is correct |
4 | Correct | 660 ms | 39916 KB | Output is correct |
5 | Correct | 61 ms | 5736 KB | Output is correct |
6 | Correct | 62 ms | 5848 KB | Output is correct |
7 | Correct | 62 ms | 5736 KB | Output is correct |
8 | Correct | 64 ms | 5732 KB | Output is correct |
9 | Correct | 61 ms | 5772 KB | Output is correct |
10 | Correct | 61 ms | 5732 KB | Output is correct |
11 | Correct | 63 ms | 5900 KB | Output is correct |
12 | Correct | 53 ms | 5732 KB | Output is correct |
13 | Correct | 62 ms | 5736 KB | Output is correct |
14 | Correct | 655 ms | 46388 KB | Output is correct |
15 | Incorrect | 66 ms | 5732 KB | Output isn't correct |
16 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 8 ms | 888 KB | Output is correct |
3 | Correct | 8 ms | 1148 KB | Output is correct |
4 | Incorrect | 2 ms | 376 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |