답안 #558348

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
558348 2022-05-07T06:42:25 Z InternetPerson10 이상한 기계 (APIO19_strange_device) C++17
100 / 100
774 ms 85348 KB
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int q;
    ll a, b;
    cin >> q >> a >> b;
    __int128 cyc = (__int128)a * b / __gcd(a, b + 1);
    ll MOD = 1e18 + 9;
    if(MOD > cyc) MOD = cyc;
    map<ll, int> m;
    while(q--) {
        ll l, r;
        cin >> l >> r;
        r++;
        if(r - l >= MOD) {
            m[0]++;
            m[MOD]--;
        }
        else if(r/MOD != l/MOD) {
            m[l%MOD]++;
            m[0]++;
            m[MOD]--;
            m[r%MOD]--;
        }
        else {
            m[l%MOD]++;
            m[r%MOD]--;
        }
    }
    ll ans = 0, x = 0;
    for(auto p : m) {
        if(x == 0) ans -= p.first;
        x += p.second;
        if(x == 0) ans += p.first;
    }
    cout << ans << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 6 ms 1228 KB Output is correct
3 Correct 6 ms 1224 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 320 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 6 ms 1236 KB Output is correct
17 Correct 64 ms 10272 KB Output is correct
18 Correct 0 ms 320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 236 ms 824 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 653 ms 68324 KB Output is correct
3 Correct 665 ms 68688 KB Output is correct
4 Correct 689 ms 63772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 653 ms 68324 KB Output is correct
3 Correct 665 ms 68688 KB Output is correct
4 Correct 689 ms 63772 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 637 ms 63776 KB Output is correct
7 Correct 649 ms 63968 KB Output is correct
8 Correct 639 ms 63860 KB Output is correct
9 Correct 757 ms 63796 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 653 ms 68324 KB Output is correct
3 Correct 665 ms 68688 KB Output is correct
4 Correct 689 ms 63772 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 59 ms 10276 KB Output is correct
7 Correct 59 ms 10296 KB Output is correct
8 Correct 58 ms 10180 KB Output is correct
9 Correct 63 ms 10180 KB Output is correct
10 Correct 56 ms 10188 KB Output is correct
11 Correct 56 ms 10172 KB Output is correct
12 Correct 54 ms 10208 KB Output is correct
13 Correct 62 ms 10280 KB Output is correct
14 Correct 56 ms 10184 KB Output is correct
15 Correct 67 ms 10260 KB Output is correct
16 Correct 69 ms 10220 KB Output is correct
17 Correct 61 ms 10220 KB Output is correct
18 Correct 621 ms 63664 KB Output is correct
19 Correct 770 ms 63704 KB Output is correct
20 Correct 754 ms 63692 KB Output is correct
21 Correct 59 ms 10216 KB Output is correct
22 Correct 59 ms 10256 KB Output is correct
23 Correct 110 ms 6104 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 65 ms 10256 KB Output is correct
3 Correct 66 ms 10232 KB Output is correct
4 Correct 710 ms 68288 KB Output is correct
5 Correct 64 ms 10292 KB Output is correct
6 Correct 63 ms 10164 KB Output is correct
7 Correct 66 ms 10244 KB Output is correct
8 Correct 65 ms 10208 KB Output is correct
9 Correct 66 ms 10276 KB Output is correct
10 Correct 62 ms 10288 KB Output is correct
11 Correct 62 ms 10244 KB Output is correct
12 Correct 61 ms 10188 KB Output is correct
13 Correct 70 ms 10232 KB Output is correct
14 Correct 711 ms 63692 KB Output is correct
15 Correct 62 ms 10320 KB Output is correct
16 Correct 629 ms 63564 KB Output is correct
17 Correct 618 ms 63632 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 6 ms 1228 KB Output is correct
3 Correct 6 ms 1224 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 320 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 6 ms 1236 KB Output is correct
17 Correct 64 ms 10272 KB Output is correct
18 Correct 0 ms 320 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 236 ms 824 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 653 ms 68324 KB Output is correct
31 Correct 665 ms 68688 KB Output is correct
32 Correct 689 ms 63772 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 637 ms 63776 KB Output is correct
35 Correct 649 ms 63968 KB Output is correct
36 Correct 639 ms 63860 KB Output is correct
37 Correct 757 ms 63796 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 59 ms 10276 KB Output is correct
40 Correct 59 ms 10296 KB Output is correct
41 Correct 58 ms 10180 KB Output is correct
42 Correct 63 ms 10180 KB Output is correct
43 Correct 56 ms 10188 KB Output is correct
44 Correct 56 ms 10172 KB Output is correct
45 Correct 54 ms 10208 KB Output is correct
46 Correct 62 ms 10280 KB Output is correct
47 Correct 56 ms 10184 KB Output is correct
48 Correct 67 ms 10260 KB Output is correct
49 Correct 69 ms 10220 KB Output is correct
50 Correct 61 ms 10220 KB Output is correct
51 Correct 621 ms 63664 KB Output is correct
52 Correct 770 ms 63704 KB Output is correct
53 Correct 754 ms 63692 KB Output is correct
54 Correct 59 ms 10216 KB Output is correct
55 Correct 59 ms 10256 KB Output is correct
56 Correct 110 ms 6104 KB Output is correct
57 Correct 1 ms 212 KB Output is correct
58 Correct 65 ms 10256 KB Output is correct
59 Correct 66 ms 10232 KB Output is correct
60 Correct 710 ms 68288 KB Output is correct
61 Correct 64 ms 10292 KB Output is correct
62 Correct 63 ms 10164 KB Output is correct
63 Correct 66 ms 10244 KB Output is correct
64 Correct 65 ms 10208 KB Output is correct
65 Correct 66 ms 10276 KB Output is correct
66 Correct 62 ms 10288 KB Output is correct
67 Correct 62 ms 10244 KB Output is correct
68 Correct 61 ms 10188 KB Output is correct
69 Correct 70 ms 10232 KB Output is correct
70 Correct 711 ms 63692 KB Output is correct
71 Correct 62 ms 10320 KB Output is correct
72 Correct 629 ms 63564 KB Output is correct
73 Correct 618 ms 63632 KB Output is correct
74 Correct 1 ms 212 KB Output is correct
75 Correct 1 ms 212 KB Output is correct
76 Correct 0 ms 212 KB Output is correct
77 Correct 0 ms 212 KB Output is correct
78 Correct 0 ms 212 KB Output is correct
79 Correct 6 ms 1232 KB Output is correct
80 Correct 764 ms 83924 KB Output is correct
81 Correct 741 ms 84068 KB Output is correct
82 Correct 728 ms 84236 KB Output is correct
83 Correct 750 ms 84324 KB Output is correct
84 Correct 774 ms 84764 KB Output is correct
85 Correct 746 ms 85348 KB Output is correct
86 Correct 118 ms 12848 KB Output is correct
87 Correct 1 ms 212 KB Output is correct