답안 #129728

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
129728 2019-07-13T05:55:16 Z pr3pony 이상한 기계 (APIO19_strange_device) C++14
100 / 100
1257 ms 63660 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
typedef pair<ll,ll> pll;
#define R first
#define L second
set<pll> s;
void add(pll p)
{
    for (auto it = s.lower_bound({p.L,-1}); it != end(s) && it->L <= p.R; s.erase(it++)) {
        p.L = min(p.L, it->L);
        p.R = max(p.R, it->R);
    }
    s.insert(p);
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    ll A,B,ans=0;
    cin >> n >> A >> B;
    A /= __gcd(A,B+1);
    if (A > inf / B) {
        while (n--) {
            ll l,r;
            cin >> l >> r;
            ans += r - l + 1;
        }
    } else {
        ll C = A * B;
        while (n--) {
            ll l,r;
            cin >> l >> r;
            if (r - l + 1 >= C) {
                add({C-1,0});
            } else {
                l %= C, r %= C;
                if (l <= r)
                    add({r,l});
                else
                    add({C-1,l}), add({r,0});
            }
        }
        for (auto p : s)
            ans += p.R - p.L + 1;
    }
    cout << ans << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 10 ms 1116 KB Output is correct
3 Correct 10 ms 1048 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 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 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 380 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 10 ms 1144 KB Output is correct
17 Correct 99 ms 6648 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 2 ms 256 KB Output is correct
3 Correct 2 ms 296 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 296 KB Output is correct
# 결과 실행 시간 메모리 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 376 KB Output is correct
5 Correct 538 ms 988 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 1097 ms 63516 KB Output is correct
3 Correct 1164 ms 63528 KB Output is correct
4 Correct 1194 ms 63644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 1097 ms 63516 KB Output is correct
3 Correct 1164 ms 63528 KB Output is correct
4 Correct 1194 ms 63644 KB Output is correct
5 Correct 2 ms 252 KB Output is correct
6 Correct 1110 ms 63544 KB Output is correct
7 Correct 1124 ms 63384 KB Output is correct
8 Correct 1163 ms 63588 KB Output is correct
9 Correct 1233 ms 63280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 1097 ms 63516 KB Output is correct
3 Correct 1164 ms 63528 KB Output is correct
4 Correct 1194 ms 63644 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 88 ms 7404 KB Output is correct
7 Correct 91 ms 7788 KB Output is correct
8 Correct 96 ms 7948 KB Output is correct
9 Correct 108 ms 7936 KB Output is correct
10 Correct 93 ms 7792 KB Output is correct
11 Correct 90 ms 7636 KB Output is correct
12 Correct 94 ms 7544 KB Output is correct
13 Correct 106 ms 7672 KB Output is correct
14 Correct 93 ms 7900 KB Output is correct
15 Correct 125 ms 7468 KB Output is correct
16 Correct 110 ms 7292 KB Output is correct
17 Correct 112 ms 7516 KB Output is correct
18 Correct 1088 ms 63280 KB Output is correct
19 Correct 1154 ms 63364 KB Output is correct
20 Correct 1173 ms 63464 KB Output is correct
21 Correct 94 ms 7928 KB Output is correct
22 Correct 99 ms 8004 KB Output is correct
23 Correct 192 ms 2172 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 420 KB Output is correct
2 Correct 105 ms 8040 KB Output is correct
3 Correct 107 ms 8408 KB Output is correct
4 Correct 1167 ms 63460 KB Output is correct
5 Correct 109 ms 8316 KB Output is correct
6 Correct 114 ms 8304 KB Output is correct
7 Correct 111 ms 8312 KB Output is correct
8 Correct 108 ms 8196 KB Output is correct
9 Correct 105 ms 8184 KB Output is correct
10 Correct 95 ms 8316 KB Output is correct
11 Correct 100 ms 7976 KB Output is correct
12 Correct 100 ms 7980 KB Output is correct
13 Correct 109 ms 7952 KB Output is correct
14 Correct 1231 ms 63364 KB Output is correct
15 Correct 91 ms 7080 KB Output is correct
16 Correct 1075 ms 63400 KB Output is correct
17 Correct 1076 ms 63408 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 10 ms 1116 KB Output is correct
3 Correct 10 ms 1048 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 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 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 380 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 10 ms 1144 KB Output is correct
17 Correct 99 ms 6648 KB Output is correct
18 Correct 2 ms 252 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 256 KB Output is correct
21 Correct 2 ms 296 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 296 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 3 ms 376 KB Output is correct
26 Correct 3 ms 376 KB Output is correct
27 Correct 3 ms 376 KB Output is correct
28 Correct 538 ms 988 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 1097 ms 63516 KB Output is correct
31 Correct 1164 ms 63528 KB Output is correct
32 Correct 1194 ms 63644 KB Output is correct
33 Correct 2 ms 252 KB Output is correct
34 Correct 1110 ms 63544 KB Output is correct
35 Correct 1124 ms 63384 KB Output is correct
36 Correct 1163 ms 63588 KB Output is correct
37 Correct 1233 ms 63280 KB Output is correct
38 Correct 2 ms 348 KB Output is correct
39 Correct 88 ms 7404 KB Output is correct
40 Correct 91 ms 7788 KB Output is correct
41 Correct 96 ms 7948 KB Output is correct
42 Correct 108 ms 7936 KB Output is correct
43 Correct 93 ms 7792 KB Output is correct
44 Correct 90 ms 7636 KB Output is correct
45 Correct 94 ms 7544 KB Output is correct
46 Correct 106 ms 7672 KB Output is correct
47 Correct 93 ms 7900 KB Output is correct
48 Correct 125 ms 7468 KB Output is correct
49 Correct 110 ms 7292 KB Output is correct
50 Correct 112 ms 7516 KB Output is correct
51 Correct 1088 ms 63280 KB Output is correct
52 Correct 1154 ms 63364 KB Output is correct
53 Correct 1173 ms 63464 KB Output is correct
54 Correct 94 ms 7928 KB Output is correct
55 Correct 99 ms 8004 KB Output is correct
56 Correct 192 ms 2172 KB Output is correct
57 Correct 2 ms 420 KB Output is correct
58 Correct 105 ms 8040 KB Output is correct
59 Correct 107 ms 8408 KB Output is correct
60 Correct 1167 ms 63460 KB Output is correct
61 Correct 109 ms 8316 KB Output is correct
62 Correct 114 ms 8304 KB Output is correct
63 Correct 111 ms 8312 KB Output is correct
64 Correct 108 ms 8196 KB Output is correct
65 Correct 105 ms 8184 KB Output is correct
66 Correct 95 ms 8316 KB Output is correct
67 Correct 100 ms 7976 KB Output is correct
68 Correct 100 ms 7980 KB Output is correct
69 Correct 109 ms 7952 KB Output is correct
70 Correct 1231 ms 63364 KB Output is correct
71 Correct 91 ms 7080 KB Output is correct
72 Correct 1075 ms 63400 KB Output is correct
73 Correct 1076 ms 63408 KB Output is correct
74 Correct 2 ms 376 KB Output is correct
75 Correct 2 ms 376 KB Output is correct
76 Correct 2 ms 376 KB Output is correct
77 Correct 2 ms 376 KB Output is correct
78 Correct 2 ms 376 KB Output is correct
79 Correct 11 ms 1272 KB Output is correct
80 Correct 1192 ms 63380 KB Output is correct
81 Correct 1154 ms 63284 KB Output is correct
82 Correct 1257 ms 63332 KB Output is correct
83 Correct 1242 ms 63420 KB Output is correct
84 Correct 1256 ms 63532 KB Output is correct
85 Correct 1189 ms 63660 KB Output is correct
86 Correct 194 ms 2040 KB Output is correct
87 Correct 2 ms 296 KB Output is correct