Submission #239871

# Submission time Handle Problem Language Result Execution time Memory
239871 2020-06-17T12:33:34 Z MrRobot_28 Vrtić (COCI18_vrtic) C++17
32 / 160
5 ms 384 KB
#include <bits/stdc++.h>
                  
using namespace std;

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin >> n;
	vector <int> p(n), c(n);
	for(int i = 0; i < n; i++)
	{
		cin >> p[i];
	}
	for(int i = 0; i < n; i++)
	{
		cin >> c[i];
	}
	sort(c.begin(), c.end());
	vector <int> ans(n);
	int res = 0;
	int iter1 = n - 1, iter2 = 0;
	for(int i = c.size() - 1; i >= 0; i--)
	{
		if(i % 2 == 0)
		{
			ans[iter1] = c[i];
			iter1--;
		}
		else
		{
			ans[iter2] = c[i];
			iter2++;
		}
	}
	for(int i= 0; i < n; i++)
	{
		res = max(res, abs(ans[i]-  ans[(i + 1) % n]));
	}
	cout << res << "\n";
	for(int i=  0; i < n; i++)
	{
		cout << ans[i] << " ";
	}
	return 0;
}	
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB the dissatisfaction value doesn't match with your answer
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB the dissatisfaction value doesn't match with your answer
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB the dissatisfaction value doesn't match with your answer
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 384 KB the dissatisfaction value doesn't match with your answer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB the dissatisfaction value doesn't match with your answer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB the dissatisfaction value doesn't match with your answer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB the dissatisfaction value doesn't match with your answer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB the dissatisfaction value doesn't match with your answer
2 Halted 0 ms 0 KB -