# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
238635 | 2020-06-12T08:33:26 Z | urd05 | 이상한 기계 (APIO19_strange_device) | C++14 | 805 ms | 33784 KB |
#include <bits/stdc++.h> using namespace std; typedef pair<long long,int> P; vector<P> v; __int128 gcd(__int128 a,__int128 b) { if (b==0) { return a; } return gcd(b,a%b); } const long long INF=2e18; bool big=false; int main(void) { int n; __int128 a,b; long long aa,bb; scanf("%d %lld %lld",&n,&aa,&bb); a=aa; b=bb; __int128 val=(a*b)/gcd(a,b+1); for(int i=0;i<n;i++) { long long l,r; scanf("%lld %lld",&l,&r); if (r-l>=val) { printf("%lld",(long long)val); return 0; } if (l/val==r/val) { v.push_back(P(l%val,1)); v.push_back(P(r%val+1,-1)); } else { v.push_back(P(0,1)); v.push_back(P(r%val+1,-1)); v.push_back(P(l%val,1)); v.push_back(P(val,-1)); } } sort(v.begin(),v.end()); long long ret=0; int sum=0; for(int i=0;i<v.size();i++) { if (sum!=0) { ret+=v[i].first-v[i-1].first; } sum+=v[i].second; } printf("%lld",ret); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 256 KB | Output is correct |
2 | Correct | 12 ms | 1276 KB | Output is correct |
3 | Correct | 12 ms | 1276 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 | 256 KB | Output is correct |
7 | Correct | 5 ms | 256 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 | 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 | 5 ms | 256 KB | Output is correct |
15 | Correct | 5 ms | 384 KB | Output is correct |
16 | Correct | 12 ms | 1276 KB | Output is correct |
17 | Correct | 84 ms | 7264 KB | Output is correct |
18 | Correct | 5 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 4 ms | 256 KB | Output is correct |
4 | Correct | 5 ms | 256 KB | Output is correct |
5 | Correct | 5 ms | 256 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 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 | 500 ms | 33380 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 256 KB | Output is correct |
2 | Correct | 665 ms | 33784 KB | Output is correct |
3 | Correct | 687 ms | 33468 KB | Output is correct |
4 | Correct | 663 ms | 33468 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 256 KB | Output is correct |
2 | Correct | 665 ms | 33784 KB | Output is correct |
3 | Correct | 687 ms | 33468 KB | Output is correct |
4 | Correct | 663 ms | 33468 KB | Output is correct |
5 | Correct | 5 ms | 256 KB | Output is correct |
6 | Correct | 677 ms | 33464 KB | Output is correct |
7 | Correct | 665 ms | 33468 KB | Output is correct |
8 | Correct | 668 ms | 33596 KB | Output is correct |
9 | Correct | 782 ms | 33468 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 256 KB | Output is correct |
2 | Correct | 665 ms | 33784 KB | Output is correct |
3 | Correct | 687 ms | 33468 KB | Output is correct |
4 | Correct | 663 ms | 33468 KB | Output is correct |
5 | Correct | 4 ms | 256 KB | Output is correct |
6 | Correct | 71 ms | 7268 KB | Output is correct |
7 | Correct | 75 ms | 7268 KB | Output is correct |
8 | Correct | 67 ms | 7268 KB | Output is correct |
9 | Correct | 69 ms | 7276 KB | Output is correct |
10 | Correct | 70 ms | 7288 KB | Output is correct |
11 | Correct | 73 ms | 7272 KB | Output is correct |
12 | Correct | 66 ms | 7272 KB | Output is correct |
13 | Correct | 81 ms | 7268 KB | Output is correct |
14 | Correct | 69 ms | 7272 KB | Output is correct |
15 | Correct | 80 ms | 7276 KB | Output is correct |
16 | Correct | 79 ms | 7268 KB | Output is correct |
17 | Correct | 69 ms | 7272 KB | Output is correct |
18 | Correct | 697 ms | 33468 KB | Output is correct |
19 | Correct | 640 ms | 33572 KB | Output is correct |
20 | Correct | 797 ms | 33472 KB | Output is correct |
21 | Correct | 81 ms | 7272 KB | Output is correct |
22 | Correct | 63 ms | 7272 KB | Output is correct |
23 | Correct | 236 ms | 20432 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 256 KB | Output is correct |
2 | Correct | 78 ms | 7140 KB | Output is correct |
3 | Correct | 80 ms | 7084 KB | Output is correct |
4 | Correct | 805 ms | 33528 KB | Output is correct |
5 | Correct | 78 ms | 7272 KB | Output is correct |
6 | Correct | 76 ms | 7272 KB | Output is correct |
7 | Correct | 76 ms | 7284 KB | Output is correct |
8 | Correct | 82 ms | 7272 KB | Output is correct |
9 | Correct | 73 ms | 7192 KB | Output is correct |
10 | Correct | 77 ms | 7240 KB | Output is correct |
11 | Correct | 76 ms | 7280 KB | Output is correct |
12 | Correct | 75 ms | 7268 KB | Output is correct |
13 | Correct | 80 ms | 7272 KB | Output is correct |
14 | Correct | 755 ms | 33340 KB | Output is correct |
15 | Correct | 81 ms | 7268 KB | Output is correct |
16 | Correct | 655 ms | 33476 KB | Output is correct |
17 | Correct | 684 ms | 33468 KB | Output is correct |
18 | Correct | 5 ms | 256 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 256 KB | Output is correct |
2 | Correct | 12 ms | 1276 KB | Output is correct |
3 | Correct | 12 ms | 1276 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 | 256 KB | Output is correct |
7 | Correct | 5 ms | 256 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 | 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 | 5 ms | 256 KB | Output is correct |
15 | Correct | 5 ms | 384 KB | Output is correct |
16 | Correct | 12 ms | 1276 KB | Output is correct |
17 | Correct | 84 ms | 7264 KB | Output is correct |
18 | Correct | 5 ms | 384 KB | Output is correct |
19 | Correct | 5 ms | 384 KB | Output is correct |
20 | Correct | 5 ms | 384 KB | Output is correct |
21 | Correct | 4 ms | 256 KB | Output is correct |
22 | Correct | 5 ms | 256 KB | Output is correct |
23 | Correct | 5 ms | 256 KB | Output is correct |
24 | Correct | 5 ms | 384 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 | 500 ms | 33380 KB | Output is correct |
29 | Correct | 4 ms | 256 KB | Output is correct |
30 | Correct | 665 ms | 33784 KB | Output is correct |
31 | Correct | 687 ms | 33468 KB | Output is correct |
32 | Correct | 663 ms | 33468 KB | Output is correct |
33 | Correct | 5 ms | 256 KB | Output is correct |
34 | Correct | 677 ms | 33464 KB | Output is correct |
35 | Correct | 665 ms | 33468 KB | Output is correct |
36 | Correct | 668 ms | 33596 KB | Output is correct |
37 | Correct | 782 ms | 33468 KB | Output is correct |
38 | Correct | 4 ms | 256 KB | Output is correct |
39 | Correct | 71 ms | 7268 KB | Output is correct |
40 | Correct | 75 ms | 7268 KB | Output is correct |
41 | Correct | 67 ms | 7268 KB | Output is correct |
42 | Correct | 69 ms | 7276 KB | Output is correct |
43 | Correct | 70 ms | 7288 KB | Output is correct |
44 | Correct | 73 ms | 7272 KB | Output is correct |
45 | Correct | 66 ms | 7272 KB | Output is correct |
46 | Correct | 81 ms | 7268 KB | Output is correct |
47 | Correct | 69 ms | 7272 KB | Output is correct |
48 | Correct | 80 ms | 7276 KB | Output is correct |
49 | Correct | 79 ms | 7268 KB | Output is correct |
50 | Correct | 69 ms | 7272 KB | Output is correct |
51 | Correct | 697 ms | 33468 KB | Output is correct |
52 | Correct | 640 ms | 33572 KB | Output is correct |
53 | Correct | 797 ms | 33472 KB | Output is correct |
54 | Correct | 81 ms | 7272 KB | Output is correct |
55 | Correct | 63 ms | 7272 KB | Output is correct |
56 | Correct | 236 ms | 20432 KB | Output is correct |
57 | Correct | 5 ms | 256 KB | Output is correct |
58 | Correct | 78 ms | 7140 KB | Output is correct |
59 | Correct | 80 ms | 7084 KB | Output is correct |
60 | Correct | 805 ms | 33528 KB | Output is correct |
61 | Correct | 78 ms | 7272 KB | Output is correct |
62 | Correct | 76 ms | 7272 KB | Output is correct |
63 | Correct | 76 ms | 7284 KB | Output is correct |
64 | Correct | 82 ms | 7272 KB | Output is correct |
65 | Correct | 73 ms | 7192 KB | Output is correct |
66 | Correct | 77 ms | 7240 KB | Output is correct |
67 | Correct | 76 ms | 7280 KB | Output is correct |
68 | Correct | 75 ms | 7268 KB | Output is correct |
69 | Correct | 80 ms | 7272 KB | Output is correct |
70 | Correct | 755 ms | 33340 KB | Output is correct |
71 | Correct | 81 ms | 7268 KB | Output is correct |
72 | Correct | 655 ms | 33476 KB | Output is correct |
73 | Correct | 684 ms | 33468 KB | Output is correct |
74 | Correct | 5 ms | 256 KB | Output is correct |
75 | Correct | 4 ms | 256 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 | 384 KB | Output is correct |
79 | Correct | 11 ms | 1404 KB | Output is correct |
80 | Correct | 785 ms | 33468 KB | Output is correct |
81 | Correct | 787 ms | 33468 KB | Output is correct |
82 | Correct | 747 ms | 33468 KB | Output is correct |
83 | Correct | 764 ms | 33468 KB | Output is correct |
84 | Correct | 767 ms | 33468 KB | Output is correct |
85 | Correct | 763 ms | 33468 KB | Output is correct |
86 | Correct | 232 ms | 20176 KB | Output is correct |
87 | Correct | 5 ms | 256 KB | Output is correct |