답안 #209158

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
209158 2020-03-13T09:51:48 Z mieszko11b 이상한 기계 (APIO19_strange_device) C++14
100 / 100
606 ms 53436 KB
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;

#define X first
#define Y second

ll INF = ll(1e18) + 7;

int n;
ll A, B, T;
vector<pll> S;

int main() {
	scanf("%d%lld%lld", &n, &A, &B);
	ll d = __gcd(A, B + 1);

	if(A / d <= INF / B)
		T = A / d * B;
	else
		T = INF;
		
	while(n--) {
		ll l, r;
		scanf("%lld%lld", &l, &r);
		if(l / T == r / T)
			S.emplace_back(l % T, r % T);
		else if(l / T == r / T - 1) {
			S.emplace_back(l % T, T - 1);
			S.emplace_back(0, r % T);
		} else {
			//~ cout << l << " " << r << endl;
			S.emplace_back(0, T - 1);
		}
	}
	
	sort(S.begin(), S.end());
	
	ll res = 0;
	ll last = -1;
	for(auto s : S) {
		//~ cout << s.X << " " << s.Y << endl;
		if(last < s.X)
			res += s.Y - s.X + 1;
		else if(last < s.Y)
			res += s.Y - last;
		last = max(last, s.Y);
	}
	
	printf("%lld\n", res);
	
	return 0;
}

Compilation message

strange_device.cpp: In function 'int main()':
strange_device.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%lld%lld", &n, &A, &B);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
strange_device.cpp:28:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld%lld", &l, &r);
   ~~~~~^~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 10 ms 1016 KB Output is correct
3 Correct 11 ms 1016 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 5 ms 256 KB Output is correct
10 Correct 5 ms 256 KB Output is correct
11 Correct 5 ms 256 KB Output is correct
12 Correct 5 ms 256 KB Output is correct
13 Correct 5 ms 256 KB Output is correct
14 Correct 4 ms 376 KB Output is correct
15 Correct 5 ms 256 KB Output is correct
16 Correct 10 ms 1144 KB Output is correct
17 Correct 63 ms 5732 KB Output is correct
18 Correct 5 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 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 256 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 432 KB Output is correct
4 Correct 5 ms 504 KB Output is correct
5 Correct 431 ms 41452 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 412 KB Output is correct
2 Correct 544 ms 29776 KB Output is correct
3 Correct 534 ms 29776 KB Output is correct
4 Correct 517 ms 53308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 412 KB Output is correct
2 Correct 544 ms 29776 KB Output is correct
3 Correct 534 ms 29776 KB Output is correct
4 Correct 517 ms 53308 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 522 ms 32512 KB Output is correct
7 Correct 532 ms 24400 KB Output is correct
8 Correct 542 ms 53436 KB Output is correct
9 Correct 570 ms 24400 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 412 KB Output is correct
2 Correct 544 ms 29776 KB Output is correct
3 Correct 534 ms 29776 KB Output is correct
4 Correct 517 ms 53308 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 59 ms 5732 KB Output is correct
7 Correct 63 ms 5732 KB Output is correct
8 Correct 61 ms 5732 KB Output is correct
9 Correct 58 ms 5732 KB Output is correct
10 Correct 62 ms 5736 KB Output is correct
11 Correct 61 ms 5732 KB Output is correct
12 Correct 56 ms 5736 KB Output is correct
13 Correct 61 ms 5868 KB Output is correct
14 Correct 59 ms 5736 KB Output is correct
15 Correct 62 ms 5784 KB Output is correct
16 Correct 62 ms 5732 KB Output is correct
17 Correct 58 ms 5860 KB Output is correct
18 Correct 569 ms 33468 KB Output is correct
19 Correct 499 ms 24876 KB Output is correct
20 Correct 592 ms 33212 KB Output is correct
21 Correct 61 ms 5732 KB Output is correct
22 Correct 53 ms 5732 KB Output is correct
23 Correct 207 ms 18524 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 63 ms 5732 KB Output is correct
3 Correct 64 ms 5732 KB Output is correct
4 Correct 590 ms 30908 KB Output is correct
5 Correct 58 ms 5732 KB Output is correct
6 Correct 57 ms 5732 KB Output is correct
7 Correct 59 ms 5860 KB Output is correct
8 Correct 63 ms 5732 KB Output is correct
9 Correct 59 ms 5736 KB Output is correct
10 Correct 58 ms 5732 KB Output is correct
11 Correct 65 ms 5736 KB Output is correct
12 Correct 54 ms 5732 KB Output is correct
13 Correct 62 ms 5736 KB Output is correct
14 Correct 577 ms 31040 KB Output is correct
15 Correct 63 ms 5708 KB Output is correct
16 Correct 582 ms 34448 KB Output is correct
17 Correct 538 ms 32444 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 10 ms 1016 KB Output is correct
3 Correct 11 ms 1016 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 5 ms 256 KB Output is correct
10 Correct 5 ms 256 KB Output is correct
11 Correct 5 ms 256 KB Output is correct
12 Correct 5 ms 256 KB Output is correct
13 Correct 5 ms 256 KB Output is correct
14 Correct 4 ms 376 KB Output is correct
15 Correct 5 ms 256 KB Output is correct
16 Correct 10 ms 1144 KB Output is correct
17 Correct 63 ms 5732 KB Output is correct
18 Correct 5 ms 256 KB Output is correct
19 Correct 4 ms 256 KB Output is correct
20 Correct 5 ms 256 KB Output is correct
21 Correct 5 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 256 KB Output is correct
25 Correct 5 ms 376 KB Output is correct
26 Correct 5 ms 432 KB Output is correct
27 Correct 5 ms 504 KB Output is correct
28 Correct 431 ms 41452 KB Output is correct
29 Correct 5 ms 412 KB Output is correct
30 Correct 544 ms 29776 KB Output is correct
31 Correct 534 ms 29776 KB Output is correct
32 Correct 517 ms 53308 KB Output is correct
33 Correct 5 ms 256 KB Output is correct
34 Correct 522 ms 32512 KB Output is correct
35 Correct 532 ms 24400 KB Output is correct
36 Correct 542 ms 53436 KB Output is correct
37 Correct 570 ms 24400 KB Output is correct
38 Correct 5 ms 256 KB Output is correct
39 Correct 59 ms 5732 KB Output is correct
40 Correct 63 ms 5732 KB Output is correct
41 Correct 61 ms 5732 KB Output is correct
42 Correct 58 ms 5732 KB Output is correct
43 Correct 62 ms 5736 KB Output is correct
44 Correct 61 ms 5732 KB Output is correct
45 Correct 56 ms 5736 KB Output is correct
46 Correct 61 ms 5868 KB Output is correct
47 Correct 59 ms 5736 KB Output is correct
48 Correct 62 ms 5784 KB Output is correct
49 Correct 62 ms 5732 KB Output is correct
50 Correct 58 ms 5860 KB Output is correct
51 Correct 569 ms 33468 KB Output is correct
52 Correct 499 ms 24876 KB Output is correct
53 Correct 592 ms 33212 KB Output is correct
54 Correct 61 ms 5732 KB Output is correct
55 Correct 53 ms 5732 KB Output is correct
56 Correct 207 ms 18524 KB Output is correct
57 Correct 5 ms 256 KB Output is correct
58 Correct 63 ms 5732 KB Output is correct
59 Correct 64 ms 5732 KB Output is correct
60 Correct 590 ms 30908 KB Output is correct
61 Correct 58 ms 5732 KB Output is correct
62 Correct 57 ms 5732 KB Output is correct
63 Correct 59 ms 5860 KB Output is correct
64 Correct 63 ms 5732 KB Output is correct
65 Correct 59 ms 5736 KB Output is correct
66 Correct 58 ms 5732 KB Output is correct
67 Correct 65 ms 5736 KB Output is correct
68 Correct 54 ms 5732 KB Output is correct
69 Correct 62 ms 5736 KB Output is correct
70 Correct 577 ms 31040 KB Output is correct
71 Correct 63 ms 5708 KB Output is correct
72 Correct 582 ms 34448 KB Output is correct
73 Correct 538 ms 32444 KB Output is correct
74 Correct 5 ms 256 KB Output is correct
75 Correct 5 ms 256 KB Output is correct
76 Correct 5 ms 256 KB Output is correct
77 Correct 5 ms 504 KB Output is correct
78 Correct 5 ms 256 KB Output is correct
79 Correct 10 ms 1012 KB Output is correct
80 Correct 606 ms 36672 KB Output is correct
81 Correct 589 ms 53340 KB Output is correct
82 Correct 561 ms 30652 KB Output is correct
83 Correct 569 ms 30656 KB Output is correct
84 Correct 558 ms 32532 KB Output is correct
85 Correct 554 ms 24496 KB Output is correct
86 Correct 211 ms 18524 KB Output is correct
87 Correct 5 ms 256 KB Output is correct