Submission #554905

# Submission time Handle Problem Language Result Execution time Memory
554905 2022-04-29T14:56:27 Z endy Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
140 ms 20092 KB
#include <bits/stdc++.h>

using namespace std;

int n;
vector <long long int > b;
vector < pair<long long int, int> > a;
vector <long long int> dif1;
vector <long long int> dif2;
long long int max1, max2;
vector < pair<int, long long int>> c;

int main(){
	
	//freopen("in.in", "r", stdin);
	ios::sync_with_stdio(false); cin.tie(0);

	cin >> n;

	for(int i=0 ; i<=n ; i++){

		long long int x;
		cin >> x;

		a.push_back(make_pair(x, i));
	}

	for(int i=0 ; i<n ; i++){

		long long int x;
		cin >> x;

		b.push_back(x);
	}

	sort(a.begin(), a.end());
	sort(b.begin(), b.end());

	for(int i=0 ; i<n ; i++){

		long long int m;

		if(a[i].first < b[i]){
			m = 0;
		}else{
			m = a[i].first - b[i];
		}

		if(max1 < m) max1 = m;

		dif1.push_back(max1);

	}


	for(int i=n-1 ; i>=0 ; i--){

		long long int m;

		if(a[i+1].first < b[i]){
			m = 0;
		}else{
			m = a[i+1].first - b[i];
		}

		if(max2 < m) max2 = m;

		dif2.push_back(max2);
	}



	int cont=0;

	while(cont <= n){

		int k;

		if(cont == 0){
			k = dif2[n-cont-1];
		}else if(cont == n){
			k = dif1[cont-1];
		}else{

			k = max(dif1[cont-1], dif2[n-cont-1]);
		}

		c.push_back(make_pair(a[cont].second, k));

		cont++;
	}

	sort(c.begin(), c.end());

	for(int i=0 ; i<=n ; i++){

		cout << c[i].second << " ";
	}

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 1 ms 468 KB Output is correct
22 Correct 1 ms 468 KB Output is correct
23 Correct 1 ms 396 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 1 ms 468 KB Output is correct
26 Correct 1 ms 468 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 1 ms 468 KB Output is correct
29 Correct 2 ms 468 KB Output is correct
30 Correct 1 ms 468 KB Output is correct
31 Correct 1 ms 468 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 1 ms 468 KB Output is correct
22 Correct 1 ms 468 KB Output is correct
23 Correct 1 ms 396 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 1 ms 468 KB Output is correct
26 Correct 1 ms 468 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 1 ms 468 KB Output is correct
29 Correct 2 ms 468 KB Output is correct
30 Correct 1 ms 468 KB Output is correct
31 Correct 1 ms 468 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
33 Correct 112 ms 16280 KB Output is correct
34 Correct 116 ms 19676 KB Output is correct
35 Correct 121 ms 19296 KB Output is correct
36 Correct 111 ms 19768 KB Output is correct
37 Correct 130 ms 20092 KB Output is correct
38 Correct 112 ms 19908 KB Output is correct
39 Correct 108 ms 18956 KB Output is correct
40 Correct 106 ms 18908 KB Output is correct
41 Correct 109 ms 19092 KB Output is correct
42 Correct 108 ms 19108 KB Output is correct
43 Correct 110 ms 19132 KB Output is correct
44 Correct 109 ms 18556 KB Output is correct
45 Correct 105 ms 18640 KB Output is correct
46 Correct 108 ms 18584 KB Output is correct
47 Correct 111 ms 18656 KB Output is correct
48 Correct 105 ms 18748 KB Output is correct
49 Correct 125 ms 19360 KB Output is correct
50 Correct 111 ms 19380 KB Output is correct
51 Correct 113 ms 19336 KB Output is correct
52 Correct 117 ms 19296 KB Output is correct
53 Correct 140 ms 19384 KB Output is correct