Submission #529050

# Submission time Handle Problem Language Result Execution time Memory
529050 2022-02-22T03:52:57 Z rk42745417 Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
298 ms 18648 KB
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(0);
using ll = int64_t;
using ull = uint64_t;
using uint = uint32_t;
using ld = long double;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const ll LINF = ll(4e18) + ll(2e15);
const double EPS = 1e-9;
static int LamyIsCute = []() {
	EmiliaMyWife
	return 48763;
}();

signed main() {
	int n;
	cin >> n;
	vector<pair<int, int>> arr(n + 1);
	vector<int> ans(n + 1), brr(n);
	for(int i = 0; i < n + 1; i++)
		cin >> arr[i].first, arr[i].second = i;
	for(int i = 0; i < n; i++)
		cin >> brr[i];
	sort(arr.begin(), arr.end());
	sort(brr.begin(), brr.end());
	multiset<int> has;
	for(int i = 0; i < n; i++)
		has.insert(arr[i + 1].first - brr[i]);

	for(int i = 0; i <= n; i++) {
		ans[arr[i].second] = *has.rbegin();

		if(i < n) {
			has.erase(has.lower_bound(arr[i + 1].first - brr[i]));
			has.insert(arr[i].first - brr[i]);
		}
	}
	for(int a : ans)
		cout << a << ' ';
	cout << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 316 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 316 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 2 ms 328 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 2 ms 460 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 2 ms 460 KB Output is correct
20 Correct 1 ms 452 KB Output is correct
21 Correct 2 ms 448 KB Output is correct
22 Correct 2 ms 460 KB Output is correct
23 Correct 2 ms 332 KB Output is correct
24 Correct 2 ms 448 KB Output is correct
25 Correct 2 ms 460 KB Output is correct
26 Correct 2 ms 368 KB Output is correct
27 Correct 2 ms 460 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 448 KB Output is correct
30 Correct 2 ms 460 KB Output is correct
31 Correct 2 ms 460 KB Output is correct
32 Correct 2 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 316 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 2 ms 328 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 2 ms 460 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 2 ms 460 KB Output is correct
20 Correct 1 ms 452 KB Output is correct
21 Correct 2 ms 448 KB Output is correct
22 Correct 2 ms 460 KB Output is correct
23 Correct 2 ms 332 KB Output is correct
24 Correct 2 ms 448 KB Output is correct
25 Correct 2 ms 460 KB Output is correct
26 Correct 2 ms 368 KB Output is correct
27 Correct 2 ms 460 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 448 KB Output is correct
30 Correct 2 ms 460 KB Output is correct
31 Correct 2 ms 460 KB Output is correct
32 Correct 2 ms 460 KB Output is correct
33 Correct 178 ms 17360 KB Output is correct
34 Correct 179 ms 18132 KB Output is correct
35 Correct 200 ms 17640 KB Output is correct
36 Correct 178 ms 18076 KB Output is correct
37 Correct 189 ms 18648 KB Output is correct
38 Correct 177 ms 18392 KB Output is correct
39 Correct 240 ms 17276 KB Output is correct
40 Correct 281 ms 17216 KB Output is correct
41 Correct 227 ms 17524 KB Output is correct
42 Correct 238 ms 17432 KB Output is correct
43 Correct 227 ms 17296 KB Output is correct
44 Correct 178 ms 16952 KB Output is correct
45 Correct 175 ms 16880 KB Output is correct
46 Correct 180 ms 16960 KB Output is correct
47 Correct 154 ms 17220 KB Output is correct
48 Correct 164 ms 17260 KB Output is correct
49 Correct 298 ms 17856 KB Output is correct
50 Correct 260 ms 17768 KB Output is correct
51 Correct 235 ms 17900 KB Output is correct
52 Correct 252 ms 18072 KB Output is correct
53 Correct 236 ms 17984 KB Output is correct