# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
246801 | 2020-07-10T10:35:17 Z | arnold518 | 이상한 기계 (APIO19_strange_device) | C++14 | 580 ms | 69652 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 1e6; const ll INF = numeric_limits<ll>::max(); ll a, b, n, ans; pll arr[MAXN+10]; int main() { int i, j; scanf("%lld%lld%lld", &n, &a, &b); for(i=1; i<=n; i++) scanf("%lld%lld", &arr[i].first, &arr[i].second); ll g=__gcd(a, b+1); a/=g; bool over = false; if(INF/b<a) over=true; else a*=b; if(over) { for(i=1; i<=n; i++) ans+=arr[i].second-arr[i].first+1; return !printf("%lld", ans); } vector<pll> A; for(i=1; i<=n; i++) { if(arr[i].second-arr[i].first+1>=a) return !printf("%lld", a); arr[i].first%=a; arr[i].second%=a; if(arr[i].second<arr[i].first) A.push_back({arr[i].first, a-1}), A.push_back({0, arr[i].second}); else A.push_back(arr[i]); } sort(A.begin(), A.end()); ll s=-1, e=-2; for(i=0; i<A.size(); i++) { if(e<A[i].first) ans+=e-s+1, s=A[i].first; e=max(e, A[i].second); } ans+=e-s+1; printf("%lld", ans); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 256 KB | Output is correct |
2 | Correct | 10 ms | 1152 KB | Output is correct |
3 | Correct | 10 ms | 1280 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 256 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 4 ms | 384 KB | Output is correct |
8 | Correct | 5 ms | 384 KB | Output is correct |
9 | Correct | 5 ms | 384 KB | Output is correct |
10 | Correct | 5 ms | 384 KB | Output is correct |
11 | Correct | 5 ms | 384 KB | Output is correct |
12 | Correct | 5 ms | 384 KB | Output is correct |
13 | Correct | 4 ms | 384 KB | Output is correct |
14 | Correct | 4 ms | 256 KB | Output is correct |
15 | Correct | 5 ms | 384 KB | Output is correct |
16 | Correct | 10 ms | 1280 KB | Output is correct |
17 | Correct | 62 ms | 7788 KB | Output is correct |
18 | Correct | 4 ms | 256 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 256 KB | Output is correct |
2 | Correct | 4 ms | 256 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 4 ms | 256 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 256 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 406 ms | 36572 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 256 KB | Output is correct |
2 | Correct | 529 ms | 53036 KB | Output is correct |
3 | Correct | 519 ms | 42848 KB | Output is correct |
4 | Correct | 500 ms | 42848 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 256 KB | Output is correct |
2 | Correct | 529 ms | 53036 KB | Output is correct |
3 | Correct | 519 ms | 42848 KB | Output is correct |
4 | Correct | 500 ms | 42848 KB | Output is correct |
5 | Correct | 4 ms | 256 KB | Output is correct |
6 | Correct | 540 ms | 42820 KB | Output is correct |
7 | Correct | 526 ms | 42868 KB | Output is correct |
8 | Correct | 507 ms | 42848 KB | Output is correct |
9 | Correct | 549 ms | 42852 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 256 KB | Output is correct |
2 | Correct | 529 ms | 53036 KB | Output is correct |
3 | Correct | 519 ms | 42848 KB | Output is correct |
4 | Correct | 500 ms | 42848 KB | Output is correct |
5 | Correct | 4 ms | 256 KB | Output is correct |
6 | Correct | 58 ms | 7792 KB | Output is correct |
7 | Correct | 61 ms | 7788 KB | Output is correct |
8 | Correct | 54 ms | 7788 KB | Output is correct |
9 | Correct | 56 ms | 7788 KB | Output is correct |
10 | Correct | 57 ms | 7788 KB | Output is correct |
11 | Correct | 60 ms | 7788 KB | Output is correct |
12 | Correct | 58 ms | 7788 KB | Output is correct |
13 | Correct | 61 ms | 7788 KB | Output is correct |
14 | Correct | 58 ms | 7788 KB | Output is correct |
15 | Correct | 61 ms | 7788 KB | Output is correct |
16 | Correct | 58 ms | 7792 KB | Output is correct |
17 | Correct | 57 ms | 7788 KB | Output is correct |
18 | Correct | 537 ms | 42840 KB | Output is correct |
19 | Correct | 498 ms | 42848 KB | Output is correct |
20 | Correct | 554 ms | 42848 KB | Output is correct |
21 | Correct | 60 ms | 7788 KB | Output is correct |
22 | Correct | 52 ms | 7788 KB | Output is correct |
23 | Correct | 197 ms | 26596 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 256 KB | Output is correct |
2 | Correct | 59 ms | 7788 KB | Output is correct |
3 | Correct | 60 ms | 7796 KB | Output is correct |
4 | Correct | 579 ms | 69652 KB | Output is correct |
5 | Correct | 57 ms | 7788 KB | Output is correct |
6 | Correct | 58 ms | 7788 KB | Output is correct |
7 | Correct | 58 ms | 7788 KB | Output is correct |
8 | Correct | 62 ms | 7788 KB | Output is correct |
9 | Correct | 57 ms | 7788 KB | Output is correct |
10 | Correct | 60 ms | 7736 KB | Output is correct |
11 | Correct | 59 ms | 7788 KB | Output is correct |
12 | Correct | 60 ms | 7788 KB | Output is correct |
13 | Correct | 60 ms | 7788 KB | Output is correct |
14 | Correct | 580 ms | 69608 KB | Output is correct |
15 | Correct | 66 ms | 7788 KB | Output is correct |
16 | Correct | 525 ms | 42848 KB | Output is correct |
17 | Correct | 528 ms | 43032 KB | Output is correct |
18 | Correct | 5 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 256 KB | Output is correct |
2 | Correct | 10 ms | 1152 KB | Output is correct |
3 | Correct | 10 ms | 1280 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 256 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 4 ms | 384 KB | Output is correct |
8 | Correct | 5 ms | 384 KB | Output is correct |
9 | Correct | 5 ms | 384 KB | Output is correct |
10 | Correct | 5 ms | 384 KB | Output is correct |
11 | Correct | 5 ms | 384 KB | Output is correct |
12 | Correct | 5 ms | 384 KB | Output is correct |
13 | Correct | 4 ms | 384 KB | Output is correct |
14 | Correct | 4 ms | 256 KB | Output is correct |
15 | Correct | 5 ms | 384 KB | Output is correct |
16 | Correct | 10 ms | 1280 KB | Output is correct |
17 | Correct | 62 ms | 7788 KB | Output is correct |
18 | Correct | 4 ms | 256 KB | Output is correct |
19 | Correct | 4 ms | 256 KB | Output is correct |
20 | Correct | 4 ms | 256 KB | Output is correct |
21 | Correct | 5 ms | 384 KB | Output is correct |
22 | Correct | 4 ms | 256 KB | Output is correct |
23 | Correct | 5 ms | 384 KB | Output is correct |
24 | Correct | 5 ms | 256 KB | Output is correct |
25 | Correct | 5 ms | 384 KB | Output is correct |
26 | Correct | 5 ms | 384 KB | Output is correct |
27 | Correct | 5 ms | 384 KB | Output is correct |
28 | Correct | 406 ms | 36572 KB | Output is correct |
29 | Correct | 4 ms | 256 KB | Output is correct |
30 | Correct | 529 ms | 53036 KB | Output is correct |
31 | Correct | 519 ms | 42848 KB | Output is correct |
32 | Correct | 500 ms | 42848 KB | Output is correct |
33 | Correct | 4 ms | 256 KB | Output is correct |
34 | Correct | 540 ms | 42820 KB | Output is correct |
35 | Correct | 526 ms | 42868 KB | Output is correct |
36 | Correct | 507 ms | 42848 KB | Output is correct |
37 | Correct | 549 ms | 42852 KB | Output is correct |
38 | Correct | 4 ms | 256 KB | Output is correct |
39 | Correct | 58 ms | 7792 KB | Output is correct |
40 | Correct | 61 ms | 7788 KB | Output is correct |
41 | Correct | 54 ms | 7788 KB | Output is correct |
42 | Correct | 56 ms | 7788 KB | Output is correct |
43 | Correct | 57 ms | 7788 KB | Output is correct |
44 | Correct | 60 ms | 7788 KB | Output is correct |
45 | Correct | 58 ms | 7788 KB | Output is correct |
46 | Correct | 61 ms | 7788 KB | Output is correct |
47 | Correct | 58 ms | 7788 KB | Output is correct |
48 | Correct | 61 ms | 7788 KB | Output is correct |
49 | Correct | 58 ms | 7792 KB | Output is correct |
50 | Correct | 57 ms | 7788 KB | Output is correct |
51 | Correct | 537 ms | 42840 KB | Output is correct |
52 | Correct | 498 ms | 42848 KB | Output is correct |
53 | Correct | 554 ms | 42848 KB | Output is correct |
54 | Correct | 60 ms | 7788 KB | Output is correct |
55 | Correct | 52 ms | 7788 KB | Output is correct |
56 | Correct | 197 ms | 26596 KB | Output is correct |
57 | Correct | 5 ms | 256 KB | Output is correct |
58 | Correct | 59 ms | 7788 KB | Output is correct |
59 | Correct | 60 ms | 7796 KB | Output is correct |
60 | Correct | 579 ms | 69652 KB | Output is correct |
61 | Correct | 57 ms | 7788 KB | Output is correct |
62 | Correct | 58 ms | 7788 KB | Output is correct |
63 | Correct | 58 ms | 7788 KB | Output is correct |
64 | Correct | 62 ms | 7788 KB | Output is correct |
65 | Correct | 57 ms | 7788 KB | Output is correct |
66 | Correct | 60 ms | 7736 KB | Output is correct |
67 | Correct | 59 ms | 7788 KB | Output is correct |
68 | Correct | 60 ms | 7788 KB | Output is correct |
69 | Correct | 60 ms | 7788 KB | Output is correct |
70 | Correct | 580 ms | 69608 KB | Output is correct |
71 | Correct | 66 ms | 7788 KB | Output is correct |
72 | Correct | 525 ms | 42848 KB | Output is correct |
73 | Correct | 528 ms | 43032 KB | Output is correct |
74 | Correct | 5 ms | 384 KB | Output is correct |
75 | Correct | 5 ms | 256 KB | Output is correct |
76 | Correct | 5 ms | 256 KB | Output is correct |
77 | Correct | 5 ms | 256 KB | Output is correct |
78 | Correct | 5 ms | 256 KB | Output is correct |
79 | Correct | 10 ms | 1280 KB | Output is correct |
80 | Correct | 575 ms | 53080 KB | Output is correct |
81 | Correct | 572 ms | 53080 KB | Output is correct |
82 | Correct | 547 ms | 53088 KB | Output is correct |
83 | Correct | 546 ms | 48096 KB | Output is correct |
84 | Correct | 533 ms | 47968 KB | Output is correct |
85 | Correct | 563 ms | 53308 KB | Output is correct |
86 | Correct | 198 ms | 26504 KB | Output is correct |
87 | Correct | 5 ms | 384 KB | Output is correct |