답안 #154712

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
154712 2019-09-23T18:59:55 Z HBK_Wasi 이상한 기계 (APIO19_strange_device) C++14
100 / 100
3139 ms 53388 KB
#include<bits/stdc++.h>
#define lli long long int
#define int long long int
#define pii pair<int, int>
 
#ifdef LOCAL
#define debug(a) cout<<#a<<' '<<a<<endl;
#endif
 
#ifndef LOCAL
#define debug(a) ;
#endif
 
using namespace std;
void faster(void)
{
	ios_base::sync_with_stdio(false);
	cin.tie();
	cout.tie();
}
 
 
int lcm(int a, int b)
{
	return (a*b)/__gcd(a,b);
} 
map<pii, bool> q; 
 
int32_t main()
{
	#ifdef LOCAL
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	#endif
 
	pii x;
	vector<pii> v;
	int i, n, A, B, l, r, mx;
	cin >> n >> A >> B;
	
	if(0==0)
	{
		int ln;
		mx = B*(A/__gcd(A, B+1));
		if((double)(log10(B)+log10(A)-log10(__gcd(A, B+1))) > 18.0) mx = 1000000000000000009;
		for(i=1;i<=n;i++)
		{
			cin >> l >> r;
			int ln = r-l;
			l = l % (mx);
			if(ln>=mx)
			{
 
				cout<<mx<<endl;
				exit(0);
			}
			if(l+ln >= mx)
			{
				v.push_back(pii(l, mx-1));
				v.push_back(pii(0, l+ln-mx));
			}
			else
			{
				v.push_back(pii(l, l+ln));
			}
		} 
		sort(v.begin(), v.end());
		int sum=0, right=-1;
		for(int i=0;i<v.size();i++)
		{
			if(v[i].first > right) sum += (v[i].second-v[i].first+1), right=v[i].second;
			else if(v[i].second > right) sum += (v[i].second-right), right=v[i].second;
		}
		cout<<sum<<endl;
		exit(0);
	}
	cout<<q.size()<<endl;
	return 0;	
}

Compilation message

strange_device.cpp: In function 'int32_t main()':
strange_device.cpp:69:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<v.size();i++)
               ~^~~~~~~~~
strange_device.cpp:43:7: warning: unused variable 'ln' [-Wunused-variable]
   int ln;
       ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 128 KB Output is correct
2 Correct 29 ms 1016 KB Output is correct
3 Correct 29 ms 1148 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 252 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 3 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 3 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 256 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 28 ms 1032 KB Output is correct
17 Correct 270 ms 4328 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 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 1902 ms 17204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2707 ms 17404 KB Output is correct
3 Correct 2624 ms 17312 KB Output is correct
4 Correct 2753 ms 17408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2707 ms 17404 KB Output is correct
3 Correct 2624 ms 17312 KB Output is correct
4 Correct 2753 ms 17408 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2634 ms 17424 KB Output is correct
7 Correct 2646 ms 17440 KB Output is correct
8 Correct 3139 ms 17552 KB Output is correct
9 Correct 2737 ms 17368 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2707 ms 17404 KB Output is correct
3 Correct 2624 ms 17312 KB Output is correct
4 Correct 2753 ms 17408 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 266 ms 4460 KB Output is correct
7 Correct 269 ms 4328 KB Output is correct
8 Correct 267 ms 4332 KB Output is correct
9 Correct 266 ms 4328 KB Output is correct
10 Correct 261 ms 4320 KB Output is correct
11 Correct 267 ms 4316 KB Output is correct
12 Correct 265 ms 4356 KB Output is correct
13 Correct 269 ms 4332 KB Output is correct
14 Correct 268 ms 4460 KB Output is correct
15 Correct 272 ms 4328 KB Output is correct
16 Correct 269 ms 4332 KB Output is correct
17 Correct 271 ms 4388 KB Output is correct
18 Correct 2630 ms 17360 KB Output is correct
19 Correct 2622 ms 17380 KB Output is correct
20 Correct 2690 ms 17228 KB Output is correct
21 Correct 269 ms 2540 KB Output is correct
22 Correct 330 ms 2540 KB Output is correct
23 Correct 877 ms 8824 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 268 ms 2540 KB Output is correct
3 Correct 270 ms 2540 KB Output is correct
4 Correct 2710 ms 17056 KB Output is correct
5 Correct 270 ms 2616 KB Output is correct
6 Correct 268 ms 2596 KB Output is correct
7 Correct 267 ms 2512 KB Output is correct
8 Correct 269 ms 2604 KB Output is correct
9 Correct 268 ms 2572 KB Output is correct
10 Correct 268 ms 2540 KB Output is correct
11 Correct 268 ms 2516 KB Output is correct
12 Correct 262 ms 2720 KB Output is correct
13 Correct 269 ms 2540 KB Output is correct
14 Correct 2685 ms 16948 KB Output is correct
15 Correct 267 ms 2540 KB Output is correct
16 Correct 2654 ms 17152 KB Output is correct
17 Correct 2616 ms 17024 KB Output is correct
18 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 128 KB Output is correct
2 Correct 29 ms 1016 KB Output is correct
3 Correct 29 ms 1148 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 252 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 3 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 3 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 256 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 28 ms 1032 KB Output is correct
17 Correct 270 ms 4328 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 256 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 256 KB Output is correct
23 Correct 2 ms 256 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 5 ms 376 KB Output is correct
26 Correct 5 ms 376 KB Output is correct
27 Correct 5 ms 376 KB Output is correct
28 Correct 1902 ms 17204 KB Output is correct
29 Correct 2 ms 256 KB Output is correct
30 Correct 2707 ms 17404 KB Output is correct
31 Correct 2624 ms 17312 KB Output is correct
32 Correct 2753 ms 17408 KB Output is correct
33 Correct 2 ms 256 KB Output is correct
34 Correct 2634 ms 17424 KB Output is correct
35 Correct 2646 ms 17440 KB Output is correct
36 Correct 3139 ms 17552 KB Output is correct
37 Correct 2737 ms 17368 KB Output is correct
38 Correct 2 ms 376 KB Output is correct
39 Correct 266 ms 4460 KB Output is correct
40 Correct 269 ms 4328 KB Output is correct
41 Correct 267 ms 4332 KB Output is correct
42 Correct 266 ms 4328 KB Output is correct
43 Correct 261 ms 4320 KB Output is correct
44 Correct 267 ms 4316 KB Output is correct
45 Correct 265 ms 4356 KB Output is correct
46 Correct 269 ms 4332 KB Output is correct
47 Correct 268 ms 4460 KB Output is correct
48 Correct 272 ms 4328 KB Output is correct
49 Correct 269 ms 4332 KB Output is correct
50 Correct 271 ms 4388 KB Output is correct
51 Correct 2630 ms 17360 KB Output is correct
52 Correct 2622 ms 17380 KB Output is correct
53 Correct 2690 ms 17228 KB Output is correct
54 Correct 269 ms 2540 KB Output is correct
55 Correct 330 ms 2540 KB Output is correct
56 Correct 877 ms 8824 KB Output is correct
57 Correct 2 ms 376 KB Output is correct
58 Correct 268 ms 2540 KB Output is correct
59 Correct 270 ms 2540 KB Output is correct
60 Correct 2710 ms 17056 KB Output is correct
61 Correct 270 ms 2616 KB Output is correct
62 Correct 268 ms 2596 KB Output is correct
63 Correct 267 ms 2512 KB Output is correct
64 Correct 269 ms 2604 KB Output is correct
65 Correct 268 ms 2572 KB Output is correct
66 Correct 268 ms 2540 KB Output is correct
67 Correct 268 ms 2516 KB Output is correct
68 Correct 262 ms 2720 KB Output is correct
69 Correct 269 ms 2540 KB Output is correct
70 Correct 2685 ms 16948 KB Output is correct
71 Correct 267 ms 2540 KB Output is correct
72 Correct 2654 ms 17152 KB Output is correct
73 Correct 2616 ms 17024 KB Output is correct
74 Correct 2 ms 256 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 360 KB Output is correct
78 Correct 2 ms 256 KB Output is correct
79 Correct 28 ms 1144 KB Output is correct
80 Correct 2738 ms 53364 KB Output is correct
81 Correct 2744 ms 53388 KB Output is correct
82 Correct 2699 ms 53376 KB Output is correct
83 Correct 2712 ms 53316 KB Output is correct
84 Correct 2700 ms 53356 KB Output is correct
85 Correct 2691 ms 53276 KB Output is correct
86 Correct 879 ms 18588 KB Output is correct
87 Correct 2 ms 376 KB Output is correct