Submission #1036614

# Submission time Handle Problem Language Result Execution time Memory
1036614 2024-07-27T14:54:13 Z Unforgettablepl Growing Vegetables is Fun 5 (JOI24_vegetables5) C++17
30 / 100
5000 ms 30292 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long

const int INF = 1e13;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	vector<int> arr(2*n+1);
	for(int i=1;i<=2*n;i++)cin>>arr[i];
	vector<int> B(n);
	for(int&i:B)cin>>i;
	sort(B.begin(),B.end());
	vector<int> C(n);
	for(int&i:C)cin>>i;
	sort(C.begin(),C.end());
	int ans = INT64_MAX;
	for(int i=1;i<=n+1;i++){
		vector<int> pota,potb;
		for(int j=i;j<i+n;j++)pota.emplace_back(arr[j]);
		for(int j=1;j<i;j++)potb.emplace_back(arr[j]);
		for(int j=i+n;j<=2*n;j++)potb.emplace_back(arr[j]);
		sort(pota.begin(),pota.end());
		sort(potb.begin(),potb.end());
		{
			int myans = 0;
			for(int j=0;j<n;j++)myans=max(myans,abs(pota[j]-B[j]));
			for(int j=0;j<n;j++)myans=max(myans,abs(potb[j]-C[j]));
			ans=min(ans,myans);
		}
		swap(pota,potb);
		{
			int myans = 0;
			for(int j=0;j<n;j++)myans=max(myans,abs(pota[j]-B[j]));
			for(int j=0;j<n;j++)myans=max(myans,abs(potb[j]-C[j]));
			ans=min(ans,myans);
		}
	}
	cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 452 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 452 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 216 ms 604 KB Output is correct
27 Correct 193 ms 604 KB Output is correct
28 Correct 95 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 193 ms 604 KB Output is correct
31 Correct 186 ms 604 KB Output is correct
32 Correct 38 ms 348 KB Output is correct
33 Correct 9 ms 348 KB Output is correct
34 Correct 215 ms 604 KB Output is correct
35 Correct 199 ms 604 KB Output is correct
36 Correct 199 ms 600 KB Output is correct
37 Correct 73 ms 604 KB Output is correct
38 Correct 92 ms 604 KB Output is correct
39 Correct 122 ms 604 KB Output is correct
40 Correct 187 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 5018 ms 30292 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 452 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 216 ms 604 KB Output is correct
27 Correct 193 ms 604 KB Output is correct
28 Correct 95 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 193 ms 604 KB Output is correct
31 Correct 186 ms 604 KB Output is correct
32 Correct 38 ms 348 KB Output is correct
33 Correct 9 ms 348 KB Output is correct
34 Correct 215 ms 604 KB Output is correct
35 Correct 199 ms 604 KB Output is correct
36 Correct 199 ms 600 KB Output is correct
37 Correct 73 ms 604 KB Output is correct
38 Correct 92 ms 604 KB Output is correct
39 Correct 122 ms 604 KB Output is correct
40 Correct 187 ms 604 KB Output is correct
41 Execution timed out 5018 ms 30292 KB Time limit exceeded
42 Halted 0 ms 0 KB -