# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
216917 | 2020-03-28T12:20:20 Z | KoalaMuch | 이상한 기계 (APIO19_strange_device) | C++14 | 595 ms | 41276 KB |
#include<bits/stdc++.h> using namespace std; vector< pair< long long,long long > > v; int main() { long long n,a,b,s,f,ans = 0,l,r; scanf("%lld %lld %lld",&n,&a,&b); a/=__gcd(a,b+1); if(a>1e18/b) a = 1e18+1; else a *=b; for(long long i=1;i<=n;i++) { scanf("%lld %lld",&l,&r); if(r-l+1>=a) v.push_back({0,a-1}); else if((r%a)<(l%a)) v.push_back({l%a,a-1}),v.push_back({0,r%a}); else v.push_back({l%a,r%a}); } sort(v.begin(),v.end()); s = v[0].first,f = v[0].second; for(int i=1;i<v.size();i++) { if(v[i].first>f) ans+=f-s+1,tie(s,f) = v[i]; else f = max(f,v[i].second); } printf("%lld\n",ans+f-s+1); return 0; } /* 3 5 10 1 20 50 68 89 98 2 16 13 2 5 18 18 3 3 3 4 4 7 9 17 18 */
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 256 KB | Output is correct |
2 | Correct | 10 ms | 1024 KB | Output is correct |
3 | Correct | 10 ms | 1152 KB | Output is correct |
4 | Correct | 4 ms | 256 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 4 ms | 256 KB | Output is correct |
7 | Correct | 5 ms | 384 KB | Output is correct |
8 | Correct | 5 ms | 256 KB | Output is correct |
9 | Correct | 5 ms | 384 KB | Output is correct |
10 | Correct | 4 ms | 256 KB | Output is correct |
11 | Correct | 5 ms | 256 KB | Output is correct |
12 | Correct | 5 ms | 384 KB | Output is correct |
13 | Correct | 5 ms | 384 KB | Output is correct |
14 | Correct | 4 ms | 256 KB | Output is correct |
15 | Correct | 4 ms | 256 KB | Output is correct |
16 | Correct | 10 ms | 1152 KB | Output is correct |
17 | Correct | 63 ms | 5736 KB | Output is correct |
18 | Correct | 5 ms | 384 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 | 4 ms | 256 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 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 | 433 ms | 41276 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 550 ms | 34284 KB | Output is correct |
3 | Correct | 524 ms | 34256 KB | Output is correct |
4 | Correct | 529 ms | 34384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 550 ms | 34284 KB | Output is correct |
3 | Correct | 524 ms | 34256 KB | Output is correct |
4 | Correct | 529 ms | 34384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 526 ms | 34540 KB | Output is correct |
7 | Correct | 548 ms | 34404 KB | Output is correct |
8 | Correct | 514 ms | 34260 KB | Output is correct |
9 | Correct | 571 ms | 34388 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 550 ms | 34284 KB | Output is correct |
3 | Correct | 524 ms | 34256 KB | Output is correct |
4 | Correct | 529 ms | 34384 KB | Output is correct |
5 | Correct | 6 ms | 256 KB | Output is correct |
6 | Correct | 57 ms | 5732 KB | Output is correct |
7 | Correct | 70 ms | 5876 KB | Output is correct |
8 | Correct | 53 ms | 5740 KB | Output is correct |
9 | Correct | 57 ms | 5732 KB | Output is correct |
10 | Correct | 59 ms | 5736 KB | Output is correct |
11 | Correct | 64 ms | 5732 KB | Output is correct |
12 | Correct | 55 ms | 5732 KB | Output is correct |
13 | Correct | 60 ms | 5736 KB | Output is correct |
14 | Correct | 58 ms | 5736 KB | Output is correct |
15 | Correct | 61 ms | 5860 KB | Output is correct |
16 | Correct | 68 ms | 5736 KB | Output is correct |
17 | Correct | 57 ms | 5736 KB | Output is correct |
18 | Correct | 554 ms | 33788 KB | Output is correct |
19 | Correct | 525 ms | 34256 KB | Output is correct |
20 | Correct | 582 ms | 34552 KB | Output is correct |
21 | Correct | 64 ms | 5732 KB | Output is correct |
22 | Correct | 54 ms | 5732 KB | Output is correct |
23 | Correct | 205 ms | 18524 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 256 KB | Output is correct |
2 | Correct | 63 ms | 5708 KB | Output is correct |
3 | Correct | 61 ms | 5740 KB | Output is correct |
4 | Correct | 582 ms | 34256 KB | Output is correct |
5 | Correct | 58 ms | 5736 KB | Output is correct |
6 | Correct | 59 ms | 5736 KB | Output is correct |
7 | Correct | 60 ms | 5732 KB | Output is correct |
8 | Correct | 61 ms | 5732 KB | Output is correct |
9 | Correct | 57 ms | 5736 KB | Output is correct |
10 | Correct | 58 ms | 5736 KB | Output is correct |
11 | Correct | 61 ms | 5736 KB | Output is correct |
12 | Correct | 58 ms | 5736 KB | Output is correct |
13 | Correct | 61 ms | 5736 KB | Output is correct |
14 | Correct | 568 ms | 34256 KB | Output is correct |
15 | Correct | 69 ms | 6020 KB | Output is correct |
16 | Correct | 571 ms | 34256 KB | Output is correct |
17 | Correct | 541 ms | 34532 KB | Output is correct |
18 | Correct | 4 ms | 256 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 256 KB | Output is correct |
2 | Correct | 10 ms | 1024 KB | Output is correct |
3 | Correct | 10 ms | 1152 KB | Output is correct |
4 | Correct | 4 ms | 256 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 4 ms | 256 KB | Output is correct |
7 | Correct | 5 ms | 384 KB | Output is correct |
8 | Correct | 5 ms | 256 KB | Output is correct |
9 | Correct | 5 ms | 384 KB | Output is correct |
10 | Correct | 4 ms | 256 KB | Output is correct |
11 | Correct | 5 ms | 256 KB | Output is correct |
12 | Correct | 5 ms | 384 KB | Output is correct |
13 | Correct | 5 ms | 384 KB | Output is correct |
14 | Correct | 4 ms | 256 KB | Output is correct |
15 | Correct | 4 ms | 256 KB | Output is correct |
16 | Correct | 10 ms | 1152 KB | Output is correct |
17 | Correct | 63 ms | 5736 KB | Output is correct |
18 | Correct | 5 ms | 384 KB | Output is correct |
19 | Correct | 4 ms | 256 KB | Output is correct |
20 | Correct | 4 ms | 256 KB | Output is correct |
21 | Correct | 4 ms | 256 KB | Output is correct |
22 | Correct | 5 ms | 384 KB | Output is correct |
23 | Correct | 5 ms | 384 KB | Output is correct |
24 | Correct | 4 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 | 433 ms | 41276 KB | Output is correct |
29 | Correct | 5 ms | 384 KB | Output is correct |
30 | Correct | 550 ms | 34284 KB | Output is correct |
31 | Correct | 524 ms | 34256 KB | Output is correct |
32 | Correct | 529 ms | 34384 KB | Output is correct |
33 | Correct | 5 ms | 384 KB | Output is correct |
34 | Correct | 526 ms | 34540 KB | Output is correct |
35 | Correct | 548 ms | 34404 KB | Output is correct |
36 | Correct | 514 ms | 34260 KB | Output is correct |
37 | Correct | 571 ms | 34388 KB | Output is correct |
38 | Correct | 6 ms | 256 KB | Output is correct |
39 | Correct | 57 ms | 5732 KB | Output is correct |
40 | Correct | 70 ms | 5876 KB | Output is correct |
41 | Correct | 53 ms | 5740 KB | Output is correct |
42 | Correct | 57 ms | 5732 KB | Output is correct |
43 | Correct | 59 ms | 5736 KB | Output is correct |
44 | Correct | 64 ms | 5732 KB | Output is correct |
45 | Correct | 55 ms | 5732 KB | Output is correct |
46 | Correct | 60 ms | 5736 KB | Output is correct |
47 | Correct | 58 ms | 5736 KB | Output is correct |
48 | Correct | 61 ms | 5860 KB | Output is correct |
49 | Correct | 68 ms | 5736 KB | Output is correct |
50 | Correct | 57 ms | 5736 KB | Output is correct |
51 | Correct | 554 ms | 33788 KB | Output is correct |
52 | Correct | 525 ms | 34256 KB | Output is correct |
53 | Correct | 582 ms | 34552 KB | Output is correct |
54 | Correct | 64 ms | 5732 KB | Output is correct |
55 | Correct | 54 ms | 5732 KB | Output is correct |
56 | Correct | 205 ms | 18524 KB | Output is correct |
57 | Correct | 5 ms | 256 KB | Output is correct |
58 | Correct | 63 ms | 5708 KB | Output is correct |
59 | Correct | 61 ms | 5740 KB | Output is correct |
60 | Correct | 582 ms | 34256 KB | Output is correct |
61 | Correct | 58 ms | 5736 KB | Output is correct |
62 | Correct | 59 ms | 5736 KB | Output is correct |
63 | Correct | 60 ms | 5732 KB | Output is correct |
64 | Correct | 61 ms | 5732 KB | Output is correct |
65 | Correct | 57 ms | 5736 KB | Output is correct |
66 | Correct | 58 ms | 5736 KB | Output is correct |
67 | Correct | 61 ms | 5736 KB | Output is correct |
68 | Correct | 58 ms | 5736 KB | Output is correct |
69 | Correct | 61 ms | 5736 KB | Output is correct |
70 | Correct | 568 ms | 34256 KB | Output is correct |
71 | Correct | 69 ms | 6020 KB | Output is correct |
72 | Correct | 571 ms | 34256 KB | Output is correct |
73 | Correct | 541 ms | 34532 KB | Output is correct |
74 | Correct | 4 ms | 256 KB | Output is correct |
75 | Correct | 4 ms | 384 KB | Output is correct |
76 | Correct | 5 ms | 256 KB | Output is correct |
77 | Correct | 4 ms | 256 KB | Output is correct |
78 | Correct | 5 ms | 256 KB | Output is correct |
79 | Correct | 10 ms | 1152 KB | Output is correct |
80 | Correct | 595 ms | 34384 KB | Output is correct |
81 | Correct | 589 ms | 34396 KB | Output is correct |
82 | Correct | 568 ms | 33980 KB | Output is correct |
83 | Correct | 555 ms | 34516 KB | Output is correct |
84 | Correct | 560 ms | 34264 KB | Output is correct |
85 | Correct | 561 ms | 34236 KB | Output is correct |
86 | Correct | 204 ms | 18524 KB | Output is correct |
87 | Correct | 5 ms | 256 KB | Output is correct |