답안 #138992

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
138992 2019-07-31T06:46:54 Z Diuven 이상한 기계 (APIO19_strange_device) C++14
100 / 100
1303 ms 65968 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long lint;
const lint LNF = 2e18;

int n;
lint A, B;

lint gcd(lint a, lint b){ return (b==0 ? a : gcd(b, a%b)); }

int main(){
	ios::sync_with_stdio(0); cin.tie(0);

	cin>>n>>A>>B;
	lint g = gcd(A, B+1), a=A/g;
	lint T = LNF;
	if(a<=LNF/B) T = a*B;

	map<lint, int> mp;
	for(int i=1; i<=n; i++){
		lint l,r; cin>>l>>r;
		if(r-l+1>=T) mp[0]++, mp[T]--;
		else{
			l%=T, r%=T;
			if(l<=r) mp[l]++, mp[r+1]--;
			else mp[0]++, mp[r+1]--, mp[l]++, mp[T]--;
		}
	}
	mp[T] = 0;
	lint xp = 0, cnt = 0, ans = 0;
	for(auto p:mp){
		lint x = p.first;
		if(cnt>0) ans += x-xp;
		cnt+=p.second;
		xp =  x;
	}
	cout<<ans<<'\n';

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 11 ms 1384 KB Output is correct
3 Correct 11 ms 1352 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 256 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 348 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 10 ms 1384 KB Output is correct
17 Correct 107 ms 10336 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 3 ms 504 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 387 ms 3316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 1075 ms 65968 KB Output is correct
3 Correct 1154 ms 64772 KB Output is correct
4 Correct 1207 ms 64584 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 1075 ms 65968 KB Output is correct
3 Correct 1154 ms 64772 KB Output is correct
4 Correct 1207 ms 64584 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 1143 ms 64580 KB Output is correct
7 Correct 1161 ms 64648 KB Output is correct
8 Correct 1137 ms 64320 KB Output is correct
9 Correct 1242 ms 64360 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 1075 ms 65968 KB Output is correct
3 Correct 1154 ms 64772 KB Output is correct
4 Correct 1207 ms 64584 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 88 ms 8412 KB Output is correct
7 Correct 92 ms 8664 KB Output is correct
8 Correct 95 ms 8952 KB Output is correct
9 Correct 107 ms 8540 KB Output is correct
10 Correct 90 ms 8568 KB Output is correct
11 Correct 91 ms 8836 KB Output is correct
12 Correct 94 ms 8912 KB Output is correct
13 Correct 109 ms 8756 KB Output is correct
14 Correct 90 ms 8460 KB Output is correct
15 Correct 115 ms 8348 KB Output is correct
16 Correct 113 ms 8376 KB Output is correct
17 Correct 106 ms 8364 KB Output is correct
18 Correct 1092 ms 64328 KB Output is correct
19 Correct 1184 ms 64352 KB Output is correct
20 Correct 1233 ms 64240 KB Output is correct
21 Correct 97 ms 8120 KB Output is correct
22 Correct 99 ms 8700 KB Output is correct
23 Correct 178 ms 4528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 110 ms 7008 KB Output is correct
3 Correct 112 ms 8048 KB Output is correct
4 Correct 1196 ms 64380 KB Output is correct
5 Correct 112 ms 8252 KB Output is correct
6 Correct 114 ms 8108 KB Output is correct
7 Correct 118 ms 8212 KB Output is correct
8 Correct 107 ms 8192 KB Output is correct
9 Correct 109 ms 8420 KB Output is correct
10 Correct 104 ms 8380 KB Output is correct
11 Correct 108 ms 8124 KB Output is correct
12 Correct 103 ms 8056 KB Output is correct
13 Correct 112 ms 8256 KB Output is correct
14 Correct 1245 ms 64220 KB Output is correct
15 Correct 94 ms 8056 KB Output is correct
16 Correct 1099 ms 64244 KB Output is correct
17 Correct 1080 ms 64380 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 11 ms 1384 KB Output is correct
3 Correct 11 ms 1352 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 256 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 348 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 10 ms 1384 KB Output is correct
17 Correct 107 ms 10336 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 3 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 3 ms 504 KB Output is correct
26 Correct 3 ms 504 KB Output is correct
27 Correct 3 ms 376 KB Output is correct
28 Correct 387 ms 3316 KB Output is correct
29 Correct 2 ms 380 KB Output is correct
30 Correct 1075 ms 65968 KB Output is correct
31 Correct 1154 ms 64772 KB Output is correct
32 Correct 1207 ms 64584 KB Output is correct
33 Correct 2 ms 376 KB Output is correct
34 Correct 1143 ms 64580 KB Output is correct
35 Correct 1161 ms 64648 KB Output is correct
36 Correct 1137 ms 64320 KB Output is correct
37 Correct 1242 ms 64360 KB Output is correct
38 Correct 2 ms 376 KB Output is correct
39 Correct 88 ms 8412 KB Output is correct
40 Correct 92 ms 8664 KB Output is correct
41 Correct 95 ms 8952 KB Output is correct
42 Correct 107 ms 8540 KB Output is correct
43 Correct 90 ms 8568 KB Output is correct
44 Correct 91 ms 8836 KB Output is correct
45 Correct 94 ms 8912 KB Output is correct
46 Correct 109 ms 8756 KB Output is correct
47 Correct 90 ms 8460 KB Output is correct
48 Correct 115 ms 8348 KB Output is correct
49 Correct 113 ms 8376 KB Output is correct
50 Correct 106 ms 8364 KB Output is correct
51 Correct 1092 ms 64328 KB Output is correct
52 Correct 1184 ms 64352 KB Output is correct
53 Correct 1233 ms 64240 KB Output is correct
54 Correct 97 ms 8120 KB Output is correct
55 Correct 99 ms 8700 KB Output is correct
56 Correct 178 ms 4528 KB Output is correct
57 Correct 2 ms 376 KB Output is correct
58 Correct 110 ms 7008 KB Output is correct
59 Correct 112 ms 8048 KB Output is correct
60 Correct 1196 ms 64380 KB Output is correct
61 Correct 112 ms 8252 KB Output is correct
62 Correct 114 ms 8108 KB Output is correct
63 Correct 118 ms 8212 KB Output is correct
64 Correct 107 ms 8192 KB Output is correct
65 Correct 109 ms 8420 KB Output is correct
66 Correct 104 ms 8380 KB Output is correct
67 Correct 108 ms 8124 KB Output is correct
68 Correct 103 ms 8056 KB Output is correct
69 Correct 112 ms 8256 KB Output is correct
70 Correct 1245 ms 64220 KB Output is correct
71 Correct 94 ms 8056 KB Output is correct
72 Correct 1099 ms 64244 KB Output is correct
73 Correct 1080 ms 64380 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 1400 KB Output is correct
80 Correct 1303 ms 64936 KB Output is correct
81 Correct 1199 ms 65044 KB Output is correct
82 Correct 1256 ms 64916 KB Output is correct
83 Correct 1233 ms 64924 KB Output is correct
84 Correct 1279 ms 65028 KB Output is correct
85 Correct 1211 ms 65232 KB Output is correct
86 Correct 177 ms 11500 KB Output is correct
87 Correct 2 ms 376 KB Output is correct