Submission #83176

# Submission time Handle Problem Language Result Execution time Memory
83176 2018-11-05T22:07:35 Z heon Cipele (COCI18_cipele) C++11
18 / 90
52 ms 9596 KB
#include<bits/stdc++.h>

using namespace std;

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int l,r;
	cin >> l >> r;
	vector <int> a, b;

	for(int i = 0; i < l; i++){
		int input;
		cin >> input;
		a.push_back(input);
	}
	for(int i = 0; i < r; i++){
		int input;
		cin >> input;
		b.push_back(input);
	}

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

	if(l < r){
		int first = a[0];
		auto pt = upper_bound(b.begin(), b.end(), first);
		--pt;
		int ind = (pt - b.begin());
		while(ind + l > r) ind--;
		int mx = 0;
		for(int i = 0; i < l; i++){
			mx = max(mx, abs(a[i] - b[i + ind]));
		}
		cout << mx;
	}
	else if(r < l){
		int first = b[0];
		auto pt = upper_bound(a.begin(), a.end(), first);
		int ind = (pt - a.begin());
		while(ind + r > l) ind--;
		int mx = 0;
		for(int i = 0; i < r; i++){
			mx = max(mx, abs(b[i] - a[i + ind]));
		}
		cout << mx;
	}
	else{
		int mx = 0;
		for(int i = 0; i < l; i++){
			mx = max(mx, abs(a[i] - b[i]));
		}
		cout << mx;
	}

}
# Verdict Execution time Memory Grader output
1 Correct 32 ms 3072 KB Output is correct
2 Correct 49 ms 4852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 52 ms 6504 KB Output is correct
2 Correct 48 ms 8524 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 8524 KB Output is correct
2 Incorrect 5 ms 8524 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 8524 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 8524 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 8524 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 8524 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 39 ms 8524 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 44 ms 8524 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 42 ms 9596 KB Output isn't correct
2 Halted 0 ms 0 KB -