Submission #146381

# Submission time Handle Problem Language Result Execution time Memory
146381 2019-08-23T16:07:20 Z badrovinho Cipele (COCI18_cipele) C++11
27 / 90
167 ms 1884 KB
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>

using namespace std;

	int l[100005];
	int r[100005];

int main (){
	
	int n,m;
	cin >> n >> m;
	
	for (int i = 0; i < n; i++){
		cin >> l[i];
	}
	
	for (int i = 0; i < m; i++){
		cin >> r[i];
	}
	
	sort(l, l + n);
	sort(r, r + m);
	
	int lo = 0;
	int hi = 1000000000;
	int mid = hi / 2;
	
	while (lo != hi){
		
		if (n >= m){
			int raz = n - m;
			int ptl = 0;
			int ptr = 0;
			int sol = 0;
			for (int i = 0; i < m; i++){
				for (int j = 0; j < raz + 1; j++){
					if ((abs (l[ptl]-r[ptr])) <= mid){
						ptr++;
						ptl++;
					}
					if ((abs (l[ptl]-r[ptr])) > mid){
						sol++;
						ptl++;
					}
				}
			}
			if (sol > raz){
				lo = mid+1;
				mid = (hi+lo)/2;
			}else {
				hi = mid;
				mid = (hi+lo)/2;
			}
		}else {
		
			int raz = m - n;
			int ptl = 0;
			int ptr = 0;
			int sol = 0;
			for (int i = 0; i < n; i++){
				for (int j = 0; j < raz + 1; j++){
					if ((abs (r[ptr]-l[ptl])) <= mid){
						ptr++;
						ptl++;
					}
					if ((abs (r[ptr]-l[ptl])) > mid){
						sol++;
						ptr++;
					}
				}
			}
			if (sol > raz){
				lo = mid+1;
				mid = (hi+lo)/2;
			}else {
				hi = mid;
				mid = (hi+lo)/2;
			}
		
		}
		
	}
	
	cout << mid;
	
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 138 ms 1236 KB Output is correct
2 Correct 165 ms 1148 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 164 ms 1132 KB Output is correct
2 Correct 167 ms 1200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 13 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 9 ms 476 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 127 ms 1656 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 141 ms 1884 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 124 ms 1716 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -