# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
153889 | 2019-09-17T10:55:49 Z | DystoriaX | 이상한 기계 (APIO19_strange_device) | C++14 | 618 ms | 19120 KB |
#include <bits/stdc++.h> using namespace std; int n; long long a, b, mx; 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(log10l(mx) + log10l(b) > 18){ 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 8 ms | 1144 KB | Output is correct |
3 | Correct | 8 ms | 1016 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 348 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 348 KB | Output is correct |
8 | Correct | 2 ms | 348 KB | Output is correct |
9 | Correct | 2 ms | 256 KB | Output is correct |
10 | Correct | 2 ms | 380 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 | 424 KB | Output is correct |
14 | Correct | 2 ms | 256 KB | Output is correct |
15 | Correct | 2 ms | 296 KB | Output is correct |
16 | Correct | 8 ms | 1016 KB | Output is correct |
17 | Correct | 65 ms | 3936 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Incorrect | 2 ms | 256 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 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 | 408 KB | Output is correct |
5 | Correct | 427 ms | 18332 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 615 ms | 18484 KB | Output is correct |
3 | Correct | 562 ms | 17968 KB | Output is correct |
4 | Correct | 532 ms | 17948 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 615 ms | 18484 KB | Output is correct |
3 | Correct | 562 ms | 17968 KB | Output is correct |
4 | Correct | 532 ms | 17948 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 549 ms | 17804 KB | Output is correct |
7 | Correct | 569 ms | 18296 KB | Output is correct |
8 | Correct | 552 ms | 18064 KB | Output is correct |
9 | Correct | 592 ms | 17616 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 615 ms | 18484 KB | Output is correct |
3 | Correct | 562 ms | 17968 KB | Output is correct |
4 | Correct | 532 ms | 17948 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 57 ms | 3176 KB | Output is correct |
7 | Correct | 60 ms | 3148 KB | Output is correct |
8 | Correct | 55 ms | 3304 KB | Output is correct |
9 | Correct | 57 ms | 2848 KB | Output is correct |
10 | Correct | 58 ms | 2968 KB | Output is correct |
11 | Correct | 60 ms | 2972 KB | Output is correct |
12 | Correct | 55 ms | 3052 KB | Output is correct |
13 | Correct | 60 ms | 2968 KB | Output is correct |
14 | Correct | 57 ms | 3048 KB | Output is correct |
15 | Correct | 65 ms | 3080 KB | Output is correct |
16 | Correct | 62 ms | 2824 KB | Output is correct |
17 | Correct | 58 ms | 2900 KB | Output is correct |
18 | Correct | 558 ms | 16848 KB | Output is correct |
19 | Correct | 535 ms | 17104 KB | Output is correct |
20 | Correct | 602 ms | 18684 KB | Output is correct |
21 | Correct | 65 ms | 4068 KB | Output is correct |
22 | Correct | 56 ms | 4212 KB | Output is correct |
23 | Correct | 213 ms | 11616 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 62 ms | 4328 KB | Output is correct |
3 | Correct | 62 ms | 4068 KB | Output is correct |
4 | Correct | 618 ms | 18480 KB | Output is correct |
5 | Correct | 62 ms | 4196 KB | Output is correct |
6 | Correct | 61 ms | 4352 KB | Output is correct |
7 | Correct | 61 ms | 4196 KB | Output is correct |
8 | Correct | 65 ms | 4196 KB | Output is correct |
9 | Correct | 59 ms | 4196 KB | Output is correct |
10 | Correct | 60 ms | 4264 KB | Output is correct |
11 | Correct | 62 ms | 4396 KB | Output is correct |
12 | Correct | 54 ms | 4472 KB | Output is correct |
13 | Correct | 64 ms | 4456 KB | Output is correct |
14 | Correct | 604 ms | 18824 KB | Output is correct |
15 | Correct | 62 ms | 4332 KB | Output is correct |
16 | Correct | 565 ms | 19036 KB | Output is correct |
17 | Correct | 553 ms | 19120 KB | Output is correct |
18 | Correct | 2 ms | 352 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 8 ms | 1144 KB | Output is correct |
3 | Correct | 8 ms | 1016 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 348 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 348 KB | Output is correct |
8 | Correct | 2 ms | 348 KB | Output is correct |
9 | Correct | 2 ms | 256 KB | Output is correct |
10 | Correct | 2 ms | 380 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 | 424 KB | Output is correct |
14 | Correct | 2 ms | 256 KB | Output is correct |
15 | Correct | 2 ms | 296 KB | Output is correct |
16 | Correct | 8 ms | 1016 KB | Output is correct |
17 | Correct | 65 ms | 3936 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
19 | Correct | 2 ms | 376 KB | Output is correct |
20 | Incorrect | 2 ms | 256 KB | Output isn't correct |
21 | Halted | 0 ms | 0 KB | - |