Submission #364781

# Submission time Handle Problem Language Result Execution time Memory
364781 2021-02-10T03:18:19 Z Rainbowbunny Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
128 ms 10860 KB
#include <iostream>
#include <algorithm>

int n;
int prefix[200005], suffix[200005], ans[200005];
std::pair <int, int> a[200005];
int b[200005];

int main()
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout.tie(0);
	std::cin >> n;
	for(int i = 1; i <= n + 1; i++)
	{
		std::cin >> a[i].first;
		a[i].second = i;
	}
	std::sort(a + 1, a + n + 2);
	for(int i = 1; i <= n; i++)
	{
		std::cin >> b[i];
	}
	std::sort(b + 1, b + n + 1);
	for(int i = 1; i <= n; i++)
	{
		prefix[i] = std::max(prefix[i - 1], a[i].first - b[i]);
	}
	for(int i = n + 1; i >= 2; i--)
	{
		suffix[i] = std::max(suffix[i + 1], a[i].first - b[i - 1]);
	}
	for(int i = 1; i <= n + 1; i++)
	{
		ans[a[i].second] = std::max(prefix[i - 1], suffix[i + 1]);
	}
	for(int i = 1; i <= n + 1; i++)
	{
		std::cout << ans[i] << ' ';
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 492 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 492 KB Output is correct
18 Correct 2 ms 512 KB Output is correct
19 Correct 1 ms 492 KB Output is correct
20 Correct 1 ms 492 KB Output is correct
21 Correct 2 ms 492 KB Output is correct
22 Correct 1 ms 492 KB Output is correct
23 Correct 1 ms 492 KB Output is correct
24 Correct 1 ms 492 KB Output is correct
25 Correct 2 ms 492 KB Output is correct
26 Correct 2 ms 492 KB Output is correct
27 Correct 2 ms 492 KB Output is correct
28 Correct 2 ms 492 KB Output is correct
29 Correct 2 ms 492 KB Output is correct
30 Correct 1 ms 492 KB Output is correct
31 Correct 1 ms 492 KB Output is correct
32 Correct 2 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 492 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 492 KB Output is correct
18 Correct 2 ms 512 KB Output is correct
19 Correct 1 ms 492 KB Output is correct
20 Correct 1 ms 492 KB Output is correct
21 Correct 2 ms 492 KB Output is correct
22 Correct 1 ms 492 KB Output is correct
23 Correct 1 ms 492 KB Output is correct
24 Correct 1 ms 492 KB Output is correct
25 Correct 2 ms 492 KB Output is correct
26 Correct 2 ms 492 KB Output is correct
27 Correct 2 ms 492 KB Output is correct
28 Correct 2 ms 492 KB Output is correct
29 Correct 2 ms 492 KB Output is correct
30 Correct 1 ms 492 KB Output is correct
31 Correct 1 ms 492 KB Output is correct
32 Correct 2 ms 492 KB Output is correct
33 Correct 102 ms 10012 KB Output is correct
34 Correct 104 ms 10396 KB Output is correct
35 Correct 112 ms 10068 KB Output is correct
36 Correct 128 ms 10604 KB Output is correct
37 Correct 107 ms 10860 KB Output is correct
38 Correct 105 ms 10732 KB Output is correct
39 Correct 101 ms 9836 KB Output is correct
40 Correct 103 ms 9836 KB Output is correct
41 Correct 122 ms 9964 KB Output is correct
42 Correct 111 ms 10016 KB Output is correct
43 Correct 102 ms 9836 KB Output is correct
44 Correct 111 ms 9452 KB Output is correct
45 Correct 108 ms 9580 KB Output is correct
46 Correct 99 ms 9452 KB Output is correct
47 Correct 99 ms 9580 KB Output is correct
48 Correct 99 ms 9452 KB Output is correct
49 Correct 106 ms 10092 KB Output is correct
50 Correct 107 ms 10092 KB Output is correct
51 Correct 104 ms 10092 KB Output is correct
52 Correct 105 ms 10092 KB Output is correct
53 Correct 108 ms 10092 KB Output is correct