Submission #567069

# Submission time Handle Problem Language Result Execution time Memory
567069 2022-05-23T07:47:46 Z haxorman Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
100 ms 10020 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long

const int mxN = 2e5 + 7;

pair<int,int> a[mxN];
int b[mxN], og[mxN], ans[mxN];

int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	int n;
	cin >> n;

	for (int i = 0; i < n + 1; ++i) {
		cin >> a[i].first;
		a[i].second = i;
	}

	for (int i = 0; i < n; ++i) {
		cin >> b[i];
	}

	sort(a, a + n + 1);	
	for (int i = 0; i < n; ++i) {
		og[a[i].second] = i;
	}

	sort(b, b + n);

	for (int i = n - 1; i >= 0; --i) {
		ans[a[n].second] = max(ans[a[n].second], a[i].first - b[i]);
	}

	for (int i = n - 1; i >= 0; --i) {
		ans[a[i].second] = max(ans[a[i + 1].second], a[i + 1].first - b[i]);
	}

	for (int i = 0; i < n + 1; ++i) {
		cout << ans[i] << ' ';
	}
	cout << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 360 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 2 ms 352 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 2 ms 340 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 360 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 2 ms 352 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 2 ms 340 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 84 ms 9244 KB Output is correct
34 Correct 91 ms 9588 KB Output is correct
35 Correct 86 ms 9324 KB Output is correct
36 Correct 85 ms 9764 KB Output is correct
37 Correct 95 ms 10020 KB Output is correct
38 Correct 100 ms 9936 KB Output is correct
39 Correct 97 ms 8972 KB Output is correct
40 Correct 96 ms 9020 KB Output is correct
41 Correct 96 ms 9028 KB Output is correct
42 Correct 91 ms 8988 KB Output is correct
43 Correct 89 ms 8940 KB Output is correct
44 Correct 91 ms 8652 KB Output is correct
45 Correct 95 ms 8684 KB Output is correct
46 Correct 93 ms 8652 KB Output is correct
47 Correct 88 ms 8652 KB Output is correct
48 Correct 88 ms 8640 KB Output is correct
49 Correct 93 ms 9224 KB Output is correct
50 Correct 96 ms 9264 KB Output is correct
51 Correct 97 ms 9212 KB Output is correct
52 Correct 94 ms 9312 KB Output is correct
53 Correct 84 ms 9308 KB Output is correct