# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
171750 | 2019-12-30T09:21:17 Z | Sensei | 이상한 기계 (APIO19_strange_device) | C++17 | 654 ms | 19696 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 + 1) > LLINF / y) { return LLINF; } return x / __gcd(x, y + 1) * 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 8 ms | 760 KB | Output is correct |
3 | Correct | 8 ms | 636 KB | Output is correct |
4 | Correct | 2 ms | 348 KB | Output is correct |
5 | Correct | 2 ms | 276 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 380 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 256 KB | Output is correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
12 | Correct | 2 ms | 376 KB | Output is correct |
13 | Correct | 2 ms | 256 KB | Output is correct |
14 | Correct | 2 ms | 256 KB | Output is correct |
15 | Correct | 2 ms | 376 KB | Output is correct |
16 | Correct | 8 ms | 1144 KB | Output is correct |
17 | Correct | 66 ms | 2640 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 392 KB | Output is correct |
2 | Incorrect | 2 ms | 376 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 3 ms | 380 KB | Output is correct |
5 | Correct | 429 ms | 16896 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 604 ms | 16980 KB | Output is correct |
3 | Correct | 577 ms | 16832 KB | Output is correct |
4 | Correct | 555 ms | 18768 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 604 ms | 16980 KB | Output is correct |
3 | Correct | 577 ms | 16832 KB | Output is correct |
4 | Correct | 555 ms | 18768 KB | Output is correct |
5 | Correct | 3 ms | 376 KB | Output is correct |
6 | Correct | 570 ms | 17300 KB | Output is correct |
7 | Correct | 590 ms | 17804 KB | Output is correct |
8 | Correct | 582 ms | 17852 KB | Output is correct |
9 | Correct | 637 ms | 17504 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 604 ms | 16980 KB | Output is correct |
3 | Correct | 577 ms | 16832 KB | Output is correct |
4 | Correct | 555 ms | 18768 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 58 ms | 5732 KB | Output is correct |
7 | Correct | 62 ms | 5604 KB | Output is correct |
8 | Correct | 56 ms | 5604 KB | Output is correct |
9 | Correct | 59 ms | 5368 KB | Output is correct |
10 | Correct | 58 ms | 5604 KB | Output is correct |
11 | Correct | 60 ms | 5604 KB | Output is correct |
12 | Correct | 56 ms | 5604 KB | Output is correct |
13 | Correct | 62 ms | 5228 KB | Output is correct |
14 | Correct | 57 ms | 5236 KB | Output is correct |
15 | Correct | 64 ms | 5604 KB | Output is correct |
16 | Correct | 63 ms | 5604 KB | Output is correct |
17 | Correct | 60 ms | 5576 KB | Output is correct |
18 | Correct | 591 ms | 17492 KB | Output is correct |
19 | Correct | 563 ms | 17392 KB | Output is correct |
20 | Correct | 650 ms | 17380 KB | Output is correct |
21 | Correct | 62 ms | 4968 KB | Output is correct |
22 | Correct | 53 ms | 4972 KB | Output is correct |
23 | Correct | 206 ms | 9536 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 63 ms | 2800 KB | Output is correct |
3 | Correct | 62 ms | 2800 KB | Output is correct |
4 | Correct | 649 ms | 18444 KB | Output is correct |
5 | Correct | 61 ms | 2796 KB | Output is correct |
6 | Correct | 60 ms | 2792 KB | Output is correct |
7 | Correct | 62 ms | 2796 KB | Output is correct |
8 | Correct | 64 ms | 2776 KB | Output is correct |
9 | Correct | 60 ms | 2700 KB | Output is correct |
10 | Correct | 60 ms | 2796 KB | Output is correct |
11 | Correct | 62 ms | 2920 KB | Output is correct |
12 | Correct | 52 ms | 2792 KB | Output is correct |
13 | Correct | 63 ms | 2796 KB | Output is correct |
14 | Correct | 654 ms | 19696 KB | Output is correct |
15 | Correct | 62 ms | 2792 KB | Output is correct |
16 | Correct | 582 ms | 18116 KB | Output is correct |
17 | Correct | 572 ms | 17044 KB | Output is correct |
18 | Correct | 2 ms | 252 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 8 ms | 760 KB | Output is correct |
3 | Correct | 8 ms | 636 KB | Output is correct |
4 | Correct | 2 ms | 348 KB | Output is correct |
5 | Correct | 2 ms | 276 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 380 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 256 KB | Output is correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
12 | Correct | 2 ms | 376 KB | Output is correct |
13 | Correct | 2 ms | 256 KB | Output is correct |
14 | Correct | 2 ms | 256 KB | Output is correct |
15 | Correct | 2 ms | 376 KB | Output is correct |
16 | Correct | 8 ms | 1144 KB | Output is correct |
17 | Correct | 66 ms | 2640 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
19 | Correct | 2 ms | 392 KB | Output is correct |
20 | Incorrect | 2 ms | 376 KB | Output isn't correct |
21 | Halted | 0 ms | 0 KB | - |