답안 #549897

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
549897 2022-04-16T19:17:38 Z Hanksburger 이상한 기계 (APIO19_strange_device) C++17
100 / 100
515 ms 48856 KB
#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long> > vec;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	long long n, a, b, num, curl, curr, ans=0;
	cin >> n >> a >> b;
	if (log2(a)+log2(b)>=60.0)
		num=2e18;
	else
		num=a*b/gcd(a*b, b+1);
	for (long long i=1; i<=n; i++)
	{
		long long l, r;
		cin >> l >> r;
		if (l+num<=r)
			vec.push_back({0, num-1});
		else if (l%num<=r%num)
			vec.push_back({l%num, r%num});
		else
		{
			vec.push_back({l%num, num-1});
			vec.push_back({0, r%num});
		}
	}
	sort(vec.begin(), vec.end());
	curl=vec[0].first;
	curr=vec[0].second;
	for (long long i=1; i<vec.size(); i++)
	{
		if (curr<vec[i].first)
		{
			ans+=curr-curl+1;
			curl=vec[i].first;
		}
		curr=max(curr, vec[i].second);
	}
	cout << ans+curr-curl+1;
	return 0;
}

Compilation message

strange_device.cpp: In function 'int main()':
strange_device.cpp:32:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |  for (long long i=1; i<vec.size(); i++)
      |                      ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 5 ms 984 KB Output is correct
3 Correct 5 ms 976 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 5 ms 1084 KB Output is correct
17 Correct 48 ms 3912 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 287 ms 16904 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 425 ms 17992 KB Output is correct
3 Correct 408 ms 18092 KB Output is correct
4 Correct 411 ms 18008 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 425 ms 17992 KB Output is correct
3 Correct 408 ms 18092 KB Output is correct
4 Correct 411 ms 18008 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 414 ms 17316 KB Output is correct
7 Correct 418 ms 17156 KB Output is correct
8 Correct 434 ms 18084 KB Output is correct
9 Correct 437 ms 17836 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 425 ms 17992 KB Output is correct
3 Correct 408 ms 18092 KB Output is correct
4 Correct 411 ms 18008 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 40 ms 3812 KB Output is correct
7 Correct 42 ms 3856 KB Output is correct
8 Correct 38 ms 3868 KB Output is correct
9 Correct 53 ms 3820 KB Output is correct
10 Correct 52 ms 3928 KB Output is correct
11 Correct 45 ms 3616 KB Output is correct
12 Correct 37 ms 3788 KB Output is correct
13 Correct 41 ms 3448 KB Output is correct
14 Correct 40 ms 3784 KB Output is correct
15 Correct 54 ms 3756 KB Output is correct
16 Correct 44 ms 3728 KB Output is correct
17 Correct 40 ms 3764 KB Output is correct
18 Correct 419 ms 17600 KB Output is correct
19 Correct 383 ms 17500 KB Output is correct
20 Correct 446 ms 17528 KB Output is correct
21 Correct 41 ms 3496 KB Output is correct
22 Correct 38 ms 3512 KB Output is correct
23 Correct 120 ms 9612 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 48 ms 3332 KB Output is correct
3 Correct 41 ms 3280 KB Output is correct
4 Correct 431 ms 17708 KB Output is correct
5 Correct 51 ms 3400 KB Output is correct
6 Correct 46 ms 3332 KB Output is correct
7 Correct 40 ms 3272 KB Output is correct
8 Correct 43 ms 3352 KB Output is correct
9 Correct 42 ms 3360 KB Output is correct
10 Correct 54 ms 3324 KB Output is correct
11 Correct 43 ms 3380 KB Output is correct
12 Correct 38 ms 3340 KB Output is correct
13 Correct 41 ms 3320 KB Output is correct
14 Correct 432 ms 17008 KB Output is correct
15 Correct 46 ms 3144 KB Output is correct
16 Correct 393 ms 17056 KB Output is correct
17 Correct 381 ms 16968 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 5 ms 984 KB Output is correct
3 Correct 5 ms 976 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 5 ms 1084 KB Output is correct
17 Correct 48 ms 3912 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 320 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 320 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 287 ms 16904 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 425 ms 17992 KB Output is correct
31 Correct 408 ms 18092 KB Output is correct
32 Correct 411 ms 18008 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 414 ms 17316 KB Output is correct
35 Correct 418 ms 17156 KB Output is correct
36 Correct 434 ms 18084 KB Output is correct
37 Correct 437 ms 17836 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 40 ms 3812 KB Output is correct
40 Correct 42 ms 3856 KB Output is correct
41 Correct 38 ms 3868 KB Output is correct
42 Correct 53 ms 3820 KB Output is correct
43 Correct 52 ms 3928 KB Output is correct
44 Correct 45 ms 3616 KB Output is correct
45 Correct 37 ms 3788 KB Output is correct
46 Correct 41 ms 3448 KB Output is correct
47 Correct 40 ms 3784 KB Output is correct
48 Correct 54 ms 3756 KB Output is correct
49 Correct 44 ms 3728 KB Output is correct
50 Correct 40 ms 3764 KB Output is correct
51 Correct 419 ms 17600 KB Output is correct
52 Correct 383 ms 17500 KB Output is correct
53 Correct 446 ms 17528 KB Output is correct
54 Correct 41 ms 3496 KB Output is correct
55 Correct 38 ms 3512 KB Output is correct
56 Correct 120 ms 9612 KB Output is correct
57 Correct 1 ms 212 KB Output is correct
58 Correct 48 ms 3332 KB Output is correct
59 Correct 41 ms 3280 KB Output is correct
60 Correct 431 ms 17708 KB Output is correct
61 Correct 51 ms 3400 KB Output is correct
62 Correct 46 ms 3332 KB Output is correct
63 Correct 40 ms 3272 KB Output is correct
64 Correct 43 ms 3352 KB Output is correct
65 Correct 42 ms 3360 KB Output is correct
66 Correct 54 ms 3324 KB Output is correct
67 Correct 43 ms 3380 KB Output is correct
68 Correct 38 ms 3340 KB Output is correct
69 Correct 41 ms 3320 KB Output is correct
70 Correct 432 ms 17008 KB Output is correct
71 Correct 46 ms 3144 KB Output is correct
72 Correct 393 ms 17056 KB Output is correct
73 Correct 381 ms 16968 KB Output is correct
74 Correct 1 ms 212 KB Output is correct
75 Correct 1 ms 312 KB Output is correct
76 Correct 1 ms 212 KB Output is correct
77 Correct 1 ms 212 KB Output is correct
78 Correct 1 ms 212 KB Output is correct
79 Correct 5 ms 1060 KB Output is correct
80 Correct 470 ms 48704 KB Output is correct
81 Correct 484 ms 48856 KB Output is correct
82 Correct 515 ms 36260 KB Output is correct
83 Correct 467 ms 40656 KB Output is correct
84 Correct 464 ms 36128 KB Output is correct
85 Correct 443 ms 36096 KB Output is correct
86 Correct 131 ms 18488 KB Output is correct
87 Correct 1 ms 212 KB Output is correct