Submission #590630

# Submission time Handle Problem Language Result Execution time Memory
590630 2022-07-06T07:48:35 Z starchan Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
99 ms 15604 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define in pair<int, int>
#define f first
#define s second
#define pb push_back
#define pob pop_back
#define INF (int)1e17
#define MX (int)3e5+5
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL)
signed main()
{
	fast();
	int n;
	cin >> n;
	vector<in> a(n+2);
	vector<int> b(n+1);
	for(int i = 1; i <= n+1; i++)
	{
		cin >> a[i].f;
		a[i].s = i;
	}
	sort(a.begin(), a.end());
	for(int i = 1; i <= n; i++)
		cin >> b[i];
	sort(b.begin(), b.end());
	vector<int> c(n+2);
	vector<int> pref_max(n+1);
	vector<int> suff_max(n+3);
	pref_max[0] = 0;
	suff_max[n+2] = 0;
	for(int i = 1; i <= n; i++)
		pref_max[i] = max(pref_max[i-1], a[i].f-b[i]);
	for(int i = n+1; i >= 2; i--)
		suff_max[i] = max(suff_max[i+1], a[i].f-b[i-1]);
	for(int i = 1; i <= n+1; i++)
		c[a[i].s] = max(pref_max[i-1], suff_max[i+1]);
	for(int i = 1; i <= n+1; i++)
		cout << c[i] << " ";
	return 0;
}	
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 316 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 316 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 400 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 336 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 2 ms 340 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 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 392 KB Output is correct
32 Correct 1 ms 400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 316 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 400 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 336 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 2 ms 340 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 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 392 KB Output is correct
32 Correct 1 ms 400 KB Output is correct
33 Correct 91 ms 14356 KB Output is correct
34 Correct 85 ms 14944 KB Output is correct
35 Correct 99 ms 14548 KB Output is correct
36 Correct 84 ms 14952 KB Output is correct
37 Correct 87 ms 15604 KB Output is correct
38 Correct 83 ms 15292 KB Output is correct
39 Correct 99 ms 14348 KB Output is correct
40 Correct 82 ms 14204 KB Output is correct
41 Correct 88 ms 14412 KB Output is correct
42 Correct 92 ms 14356 KB Output is correct
43 Correct 82 ms 14200 KB Output is correct
44 Correct 80 ms 13736 KB Output is correct
45 Correct 81 ms 13900 KB Output is correct
46 Correct 80 ms 13740 KB Output is correct
47 Correct 91 ms 14092 KB Output is correct
48 Correct 81 ms 14084 KB Output is correct
49 Correct 94 ms 14724 KB Output is correct
50 Correct 84 ms 14720 KB Output is correct
51 Correct 88 ms 14752 KB Output is correct
52 Correct 89 ms 14720 KB Output is correct
53 Correct 88 ms 14724 KB Output is correct