Submission #925195

# Submission time Handle Problem Language Result Execution time Memory
925195 2024-02-11T00:53:48 Z ymwang Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
74 ms 13900 KB
#include <bits/stdc++.h>
using namespace std;
using pii = pair<long long, int>;

const int N = 2e5+5;

pii a[N];
long long b[N], suf[N], ans[N];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.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(b, b+n);
	sort(a, a+n+1);
	for(int i=n; i>0; i--)
		suf[i] = max(suf[i+1], a[i].first - b[i-1]);

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

	for(int i=0; i<n+1; i++)
		cout << ans[i] << " ";
	cout << "\n";
}
/*
3
4 3 7 6
2 6 4
*/
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4552 KB Output is correct
2 Correct 4 ms 4440 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4440 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4552 KB Output is correct
2 Correct 4 ms 4440 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4440 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 2 ms 4444 KB Output is correct
18 Correct 1 ms 4440 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 4444 KB Output is correct
21 Correct 1 ms 4444 KB Output is correct
22 Correct 1 ms 4444 KB Output is correct
23 Correct 1 ms 4444 KB Output is correct
24 Correct 1 ms 4572 KB Output is correct
25 Correct 1 ms 4444 KB Output is correct
26 Correct 1 ms 4608 KB Output is correct
27 Correct 1 ms 4444 KB Output is correct
28 Correct 2 ms 4440 KB Output is correct
29 Correct 1 ms 4440 KB Output is correct
30 Correct 1 ms 4444 KB Output is correct
31 Correct 2 ms 4444 KB Output is correct
32 Correct 1 ms 4444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4552 KB Output is correct
2 Correct 4 ms 4440 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4440 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 2 ms 4444 KB Output is correct
18 Correct 1 ms 4440 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 4444 KB Output is correct
21 Correct 1 ms 4444 KB Output is correct
22 Correct 1 ms 4444 KB Output is correct
23 Correct 1 ms 4444 KB Output is correct
24 Correct 1 ms 4572 KB Output is correct
25 Correct 1 ms 4444 KB Output is correct
26 Correct 1 ms 4608 KB Output is correct
27 Correct 1 ms 4444 KB Output is correct
28 Correct 2 ms 4440 KB Output is correct
29 Correct 1 ms 4440 KB Output is correct
30 Correct 1 ms 4444 KB Output is correct
31 Correct 2 ms 4444 KB Output is correct
32 Correct 1 ms 4444 KB Output is correct
33 Correct 67 ms 13152 KB Output is correct
34 Correct 73 ms 13648 KB Output is correct
35 Correct 67 ms 13332 KB Output is correct
36 Correct 67 ms 13648 KB Output is correct
37 Correct 71 ms 13900 KB Output is correct
38 Correct 72 ms 13884 KB Output is correct
39 Correct 69 ms 13040 KB Output is correct
40 Correct 68 ms 12884 KB Output is correct
41 Correct 67 ms 13136 KB Output is correct
42 Correct 67 ms 13072 KB Output is correct
43 Correct 67 ms 13024 KB Output is correct
44 Correct 68 ms 12632 KB Output is correct
45 Correct 74 ms 12624 KB Output is correct
46 Correct 66 ms 12628 KB Output is correct
47 Correct 63 ms 12624 KB Output is correct
48 Correct 65 ms 12496 KB Output is correct
49 Correct 70 ms 13236 KB Output is correct
50 Correct 70 ms 13220 KB Output is correct
51 Correct 69 ms 13240 KB Output is correct
52 Correct 71 ms 13072 KB Output is correct
53 Correct 70 ms 13244 KB Output is correct