Submission #549895

# Submission time Handle Problem Language Result Execution time Memory
549895 2022-04-16T19:08:53 Z Hanksburger Strange Device (APIO19_strange_device) C++17
35 / 100
510 ms 49908 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;
	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:29: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]
   29 |  for (long long i=1; i<vec.size(); i++)
      |                      ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 7 ms 1056 KB Output is correct
3 Correct 6 ms 1076 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 316 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 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 324 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 7 ms 1056 KB Output is correct
17 Correct 50 ms 5612 KB Output is correct
18 Incorrect 1 ms 212 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Incorrect 0 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 351 ms 41260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 453 ms 17936 KB Output is correct
3 Correct 397 ms 17924 KB Output is correct
4 Correct 436 ms 38300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 453 ms 17936 KB Output is correct
3 Correct 397 ms 17924 KB Output is correct
4 Correct 436 ms 38300 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 443 ms 46252 KB Output is correct
7 Correct 447 ms 38460 KB Output is correct
8 Correct 472 ms 46360 KB Output is correct
9 Correct 449 ms 46228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 453 ms 17936 KB Output is correct
3 Correct 397 ms 17924 KB Output is correct
4 Correct 436 ms 38300 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 45 ms 5616 KB Output is correct
7 Correct 46 ms 5720 KB Output is correct
8 Correct 51 ms 5664 KB Output is correct
9 Correct 41 ms 5704 KB Output is correct
10 Correct 45 ms 5628 KB Output is correct
11 Correct 47 ms 5612 KB Output is correct
12 Correct 54 ms 5692 KB Output is correct
13 Correct 43 ms 5624 KB Output is correct
14 Correct 41 ms 5760 KB Output is correct
15 Correct 44 ms 5640 KB Output is correct
16 Correct 45 ms 5668 KB Output is correct
17 Correct 59 ms 5708 KB Output is correct
18 Correct 434 ms 49908 KB Output is correct
19 Correct 475 ms 46568 KB Output is correct
20 Correct 485 ms 49400 KB Output is correct
21 Correct 47 ms 5700 KB Output is correct
22 Correct 41 ms 5632 KB Output is correct
23 Correct 132 ms 18404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 61 ms 5668 KB Output is correct
3 Correct 52 ms 5800 KB Output is correct
4 Correct 510 ms 19620 KB Output is correct
5 Correct 46 ms 5816 KB Output is correct
6 Correct 45 ms 5668 KB Output is correct
7 Correct 43 ms 5728 KB Output is correct
8 Correct 53 ms 5660 KB Output is correct
9 Correct 47 ms 5700 KB Output is correct
10 Correct 46 ms 5684 KB Output is correct
11 Correct 47 ms 5820 KB Output is correct
12 Correct 42 ms 5760 KB Output is correct
13 Correct 44 ms 5688 KB Output is correct
14 Correct 478 ms 46936 KB Output is correct
15 Correct 48 ms 5716 KB Output is correct
16 Correct 454 ms 48512 KB Output is correct
17 Correct 459 ms 49280 KB Output is correct
18 Incorrect 1 ms 212 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 7 ms 1056 KB Output is correct
3 Correct 6 ms 1076 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 316 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 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 324 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 7 ms 1056 KB Output is correct
17 Correct 50 ms 5612 KB Output is correct
18 Incorrect 1 ms 212 KB Output isn't correct
19 Halted 0 ms 0 KB -