답안 #409666

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
409666 2021-05-21T10:25:50 Z glebustim 이상한 기계 (APIO19_strange_device) C++17
100 / 100
930 ms 98048 KB
#include <bits/stdc++.h>
typedef long long ll;
typedef __int128 lll;
using namespace std;

lll gcd(lll x, lll y) {
    while (y > 0) {
        lll z = x % y;
        x = y;
        y = z;
    }
    return x;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    ll _a, _b;
    cin >> n >> _a >> _b;
    lll a = _a, b = _b, len = a * b / gcd(a, b + 1);
    map<lll, int> s;
    for (int i = 0; i < n; ++i) {
        ll l, r;
        cin >> l >> r;
        lll f = l % len;
        if (f + r - l >= len) {
            ++s[0];
            --s[r % len + 1];
            ++s[f];
            --s[len];
        }
        else {
            ++s[f];
            --s[f + r - l + 1];
        }
    }
    int bal = 0;
    ll ans = 0;
    lll prev = -1;
    for (auto [t, e]: s) {
        if (bal > 0)
            ans += t - prev;
        bal += e;
        prev = t;
    }
    cout << ans << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 8 ms 1484 KB Output is correct
3 Correct 8 ms 1456 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 8 ms 1384 KB Output is correct
17 Correct 76 ms 11844 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 308 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 2 ms 460 KB Output is correct
3 Correct 2 ms 460 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
5 Correct 317 ms 800 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 799 ms 78568 KB Output is correct
3 Correct 822 ms 97796 KB Output is correct
4 Correct 905 ms 97780 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 799 ms 78568 KB Output is correct
3 Correct 822 ms 97796 KB Output is correct
4 Correct 905 ms 97780 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 863 ms 97768 KB Output is correct
7 Correct 828 ms 94648 KB Output is correct
8 Correct 855 ms 94744 KB Output is correct
9 Correct 930 ms 94752 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 799 ms 78568 KB Output is correct
3 Correct 822 ms 97796 KB Output is correct
4 Correct 905 ms 97780 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 69 ms 11748 KB Output is correct
7 Correct 71 ms 11784 KB Output is correct
8 Correct 71 ms 11840 KB Output is correct
9 Correct 84 ms 11792 KB Output is correct
10 Correct 71 ms 11820 KB Output is correct
11 Correct 69 ms 11816 KB Output is correct
12 Correct 90 ms 11836 KB Output is correct
13 Correct 76 ms 11844 KB Output is correct
14 Correct 78 ms 11844 KB Output is correct
15 Correct 93 ms 11980 KB Output is correct
16 Correct 80 ms 11824 KB Output is correct
17 Correct 74 ms 11768 KB Output is correct
18 Correct 814 ms 97848 KB Output is correct
19 Correct 867 ms 97808 KB Output is correct
20 Correct 868 ms 97828 KB Output is correct
21 Correct 75 ms 11856 KB Output is correct
22 Correct 83 ms 11732 KB Output is correct
23 Correct 151 ms 12816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 80 ms 8456 KB Output is correct
3 Correct 75 ms 8496 KB Output is correct
4 Correct 884 ms 78592 KB Output is correct
5 Correct 80 ms 8500 KB Output is correct
6 Correct 83 ms 8464 KB Output is correct
7 Correct 78 ms 8456 KB Output is correct
8 Correct 82 ms 8516 KB Output is correct
9 Correct 76 ms 8428 KB Output is correct
10 Correct 73 ms 8508 KB Output is correct
11 Correct 74 ms 8516 KB Output is correct
12 Correct 94 ms 8412 KB Output is correct
13 Correct 98 ms 8412 KB Output is correct
14 Correct 858 ms 78572 KB Output is correct
15 Correct 69 ms 8528 KB Output is correct
16 Correct 847 ms 97800 KB Output is correct
17 Correct 891 ms 97800 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 8 ms 1484 KB Output is correct
3 Correct 8 ms 1456 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 8 ms 1384 KB Output is correct
17 Correct 76 ms 11844 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 308 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 312 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 2 ms 460 KB Output is correct
26 Correct 2 ms 460 KB Output is correct
27 Correct 2 ms 332 KB Output is correct
28 Correct 317 ms 800 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 799 ms 78568 KB Output is correct
31 Correct 822 ms 97796 KB Output is correct
32 Correct 905 ms 97780 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
34 Correct 863 ms 97768 KB Output is correct
35 Correct 828 ms 94648 KB Output is correct
36 Correct 855 ms 94744 KB Output is correct
37 Correct 930 ms 94752 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 69 ms 11748 KB Output is correct
40 Correct 71 ms 11784 KB Output is correct
41 Correct 71 ms 11840 KB Output is correct
42 Correct 84 ms 11792 KB Output is correct
43 Correct 71 ms 11820 KB Output is correct
44 Correct 69 ms 11816 KB Output is correct
45 Correct 90 ms 11836 KB Output is correct
46 Correct 76 ms 11844 KB Output is correct
47 Correct 78 ms 11844 KB Output is correct
48 Correct 93 ms 11980 KB Output is correct
49 Correct 80 ms 11824 KB Output is correct
50 Correct 74 ms 11768 KB Output is correct
51 Correct 814 ms 97848 KB Output is correct
52 Correct 867 ms 97808 KB Output is correct
53 Correct 868 ms 97828 KB Output is correct
54 Correct 75 ms 11856 KB Output is correct
55 Correct 83 ms 11732 KB Output is correct
56 Correct 151 ms 12816 KB Output is correct
57 Correct 1 ms 204 KB Output is correct
58 Correct 80 ms 8456 KB Output is correct
59 Correct 75 ms 8496 KB Output is correct
60 Correct 884 ms 78592 KB Output is correct
61 Correct 80 ms 8500 KB Output is correct
62 Correct 83 ms 8464 KB Output is correct
63 Correct 78 ms 8456 KB Output is correct
64 Correct 82 ms 8516 KB Output is correct
65 Correct 76 ms 8428 KB Output is correct
66 Correct 73 ms 8508 KB Output is correct
67 Correct 74 ms 8516 KB Output is correct
68 Correct 94 ms 8412 KB Output is correct
69 Correct 98 ms 8412 KB Output is correct
70 Correct 858 ms 78572 KB Output is correct
71 Correct 69 ms 8528 KB Output is correct
72 Correct 847 ms 97800 KB Output is correct
73 Correct 891 ms 97800 KB Output is correct
74 Correct 1 ms 204 KB Output is correct
75 Correct 1 ms 204 KB Output is correct
76 Correct 1 ms 316 KB Output is correct
77 Correct 1 ms 204 KB Output is correct
78 Correct 1 ms 204 KB Output is correct
79 Correct 8 ms 1484 KB Output is correct
80 Correct 866 ms 98028 KB Output is correct
81 Correct 914 ms 97840 KB Output is correct
82 Correct 873 ms 97888 KB Output is correct
83 Correct 926 ms 97952 KB Output is correct
84 Correct 883 ms 98048 KB Output is correct
85 Correct 859 ms 97932 KB Output is correct
86 Correct 144 ms 12816 KB Output is correct
87 Correct 1 ms 204 KB Output is correct