Submission #239096

# Submission time Handle Problem Language Result Execution time Memory
239096 2020-06-14T11:29:17 Z ioilolcom Cipele (COCI18_cipele) C++14
0 / 90
83 ms 5880 KB
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;
set<int> s;
int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	int n,m; cin>>n>>m;
	vector<int> v1(n+1),v2(m+1);
	for(int i=1; i<=n; i++) {
		cin>>v1[i];
	}
	for(int i=1; i<=m; i++) {
		cin>>v2[i];
	}
	if(n>=m) {
		for(int i=1; i<=n; i++) {
			s.insert(v1[i]);
		}
		//cout<<endl;
		sort(v2.begin()+1,v2.end());
		/*
		   for(int i=1; i<=m; i++) {
		        cout<<v2[i]<<" ";
		   }
		   cout<<endl;
		 */
		int ans=0;
		for(int i=m; i>=1; i--) {
			auto d=s.lower_bound(v2[i]);
			auto d2=d;
			if(d2!=s.begin()) {
				d2--;
			}
			if(abs(*d-v2[i])<abs(*d2-v2[i])) {
				ans=max(ans,abs(*d-v2[i]));
				s.erase(*d);
			}
			else{
				ans=max(ans,abs(*d2-v2[i]));
				s.erase(*d2);
			}
		}
		cout<<ans<<endl;
	}
	else{
		for(int i=1; i<=m; i++) {
			s.insert(v2[i]);
		}
		//cout<<endl;
		sort(v1.begin()+1,v1.end());
		/*
		         for(int i=1; i<=m; i++) {
		                                cout<<v2[i]<<" ";
		         }
		         cout<<endl;
		 */
		int ans=0;
		for(int i=n; i>=1; i--) {
			auto d=s.lower_bound(v1[i]);
			auto d2=d;
			if(d2!=s.begin()) {
				d2--;
			}
			if(abs(*d-v1[i])<abs(*d2-v1[i])) {
				ans=max(ans,abs(*d-v1[i]));
				s.erase(*d);
			}
			else{
				ans=max(ans,abs(*d2-v1[i]));
				s.erase(*d2);
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 59 ms 5752 KB Output is correct
2 Incorrect 83 ms 5880 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 76 ms 5756 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 512 KB Output is correct
2 Incorrect 8 ms 640 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 640 KB Output is correct
2 Incorrect 7 ms 640 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 640 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 640 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 640 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 72 ms 5496 KB Output is correct
2 Incorrect 47 ms 3576 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 74 ms 5504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 67 ms 5240 KB Output isn't correct
2 Halted 0 ms 0 KB -