Submission #867617

# Submission time Handle Problem Language Result Execution time Memory
867617 2023-10-29T02:01:55 Z MongHwa Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
207 ms 18616 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

#define X first
#define Y second

int ans[200001];
int arr[200001];
multiset<int> ms;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);

	int n;
	cin >> n;

	vector<pair<int, int>> v;
	for(int i = 0; i <= n; i++)
	{
		int x;
		cin >> x;

		v.push_back({x, i});
	}

	for(int i = 0; i < n; i++)
		cin >> arr[i];

	sort(v.begin(), v.end());
	sort(arr, arr+n);

	for(int i = 0; i < n; i++)
		ms.insert(max(0, v[i].X-arr[i]));

	ans[v[n].Y] = *ms.rbegin();
	for(int i = n-1; i >= 0; i--)
	{
		ms.erase(ms.find(max(0, v[i].X-arr[i])));
		ms.insert(max(0, v[i+1].X-arr[i]));

		ans[v[i].Y] = *ms.rbegin();
	}

	for(int i = 0; i <= n; i++)
		cout << ans[i] << ' ';
	cout << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
20 Correct 1 ms 604 KB Output is correct
21 Correct 1 ms 604 KB Output is correct
22 Correct 1 ms 852 KB Output is correct
23 Correct 1 ms 604 KB Output is correct
24 Correct 2 ms 600 KB Output is correct
25 Correct 1 ms 604 KB Output is correct
26 Correct 1 ms 604 KB Output is correct
27 Correct 1 ms 600 KB Output is correct
28 Correct 1 ms 604 KB Output is correct
29 Correct 1 ms 604 KB Output is correct
30 Correct 1 ms 604 KB Output is correct
31 Correct 1 ms 600 KB Output is correct
32 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
20 Correct 1 ms 604 KB Output is correct
21 Correct 1 ms 604 KB Output is correct
22 Correct 1 ms 852 KB Output is correct
23 Correct 1 ms 604 KB Output is correct
24 Correct 2 ms 600 KB Output is correct
25 Correct 1 ms 604 KB Output is correct
26 Correct 1 ms 604 KB Output is correct
27 Correct 1 ms 600 KB Output is correct
28 Correct 1 ms 604 KB Output is correct
29 Correct 1 ms 604 KB Output is correct
30 Correct 1 ms 604 KB Output is correct
31 Correct 1 ms 600 KB Output is correct
32 Correct 1 ms 604 KB Output is correct
33 Correct 145 ms 17508 KB Output is correct
34 Correct 150 ms 18488 KB Output is correct
35 Correct 134 ms 17548 KB Output is correct
36 Correct 143 ms 18120 KB Output is correct
37 Correct 146 ms 18616 KB Output is correct
38 Correct 142 ms 18372 KB Output is correct
39 Correct 169 ms 17420 KB Output is correct
40 Correct 160 ms 17348 KB Output is correct
41 Correct 165 ms 17464 KB Output is correct
42 Correct 171 ms 17480 KB Output is correct
43 Correct 158 ms 17348 KB Output is correct
44 Correct 131 ms 16836 KB Output is correct
45 Correct 152 ms 16964 KB Output is correct
46 Correct 148 ms 16876 KB Output is correct
47 Correct 124 ms 17352 KB Output is correct
48 Correct 138 ms 17516 KB Output is correct
49 Correct 172 ms 17860 KB Output is correct
50 Correct 170 ms 17860 KB Output is correct
51 Correct 207 ms 18060 KB Output is correct
52 Correct 178 ms 17860 KB Output is correct
53 Correct 160 ms 17860 KB Output is correct