Submission #464707

# Submission time Handle Problem Language Result Execution time Memory
464707 2021-08-13T18:47:07 Z Hamed5001 Cipele (COCI18_cipele) C++14
27 / 90
1000 ms 1220 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
/*
	dp[i] = min ugliness if I paired first i shoes
	dp[i] = 
*/
void solve() {
	int N, M;
	cin >> N >> M;
	vector<int> A1(N), A2(M);
	for (auto& a : A1) cin >> a;
	for (auto& a : A2) cin >> a;
	sort(A1.begin(), A1.end());
	sort(A2.begin(), A2.end());

	if (N > M) {
		swap(N, M);
		swap(A1, A2);
	}

	int ans = INT_MAX;
	for (int i = 0; i+N-1 < M; i++) {
		int tmp = 0;
		for (int j = 0; j < N; j++) {
			tmp = max(tmp, abs(A1[j] - A2[i+j]));
		}
		ans = min(ans, tmp);
	}
	cout << ans;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	solve();
}
# Verdict Execution time Memory Grader output
1 Correct 26 ms 1112 KB Output is correct
2 Correct 41 ms 1136 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 46 ms 1216 KB Output is correct
2 Correct 41 ms 1220 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1077 ms 1008 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 945 ms 1100 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1070 ms 972 KB Time limit exceeded
2 Halted 0 ms 0 KB -