Submission #306415

# Submission time Handle Problem Language Result Execution time Memory
306415 2020-09-25T13:16:40 Z colazcy Cipele (COCI18_cipele) C++17
45 / 90
45 ms 2936 KB
#include <cstdio>
#include <cctype>
#include <vector>
#include <algorithm>
using namespace std;
const int maxn = 1e5 + 100;
inline int read(){
	int x = 0;char c = getchar();
	while(!isdigit(c))c = getchar();
	while(isdigit(c))x = x * 10 + c - '0',c = getchar();
	return x;
}
int n,m,va[maxn],vb[maxn];
inline bool check(int limit){
	int pos = 1;
	for(int i = 1;i <= m;i++){
		while(pos <= n && abs(va[pos] - vb[i]) > limit)pos++;
		if(pos == n + 1)return false;
		pos++;
	}
	return true;
} 
int main(){
	n = read(),m = read();
	for(int i = 1;i <= n;i++)va[i] = read();
	for(int i = 1;i <= m;i++)vb[i] = read();
	if(n < m)swap(n,m),swap(va,vb);
	sort(va + 1,va + 1 + n);
	sort(vb + 1,vb + 1 + m);
	int l = 0,r = min(abs(va[1] - vb[m]),abs(vb[1] - va[n])),ans = -1;
	while(l <= r){
		int mid = (l + r) >> 1;
		if(check(mid))ans = mid,r = mid - 1;
		else l = mid + 1;
	}
	printf("%d\n",ans);
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 28 ms 2560 KB Output is correct
2 Correct 44 ms 2936 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 2816 KB Output is correct
2 Correct 43 ms 2936 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1152 KB Output is correct
2 Incorrect 3 ms 1152 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1132 KB Output is correct
2 Incorrect 3 ms 1152 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1152 KB Output is correct
2 Incorrect 3 ms 1152 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1152 KB Output is correct
2 Incorrect 3 ms 1152 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1152 KB Output is correct
2 Incorrect 3 ms 1152 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 45 ms 2560 KB Output is correct
2 Correct 27 ms 1792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 41 ms 2688 KB Output is correct
2 Correct 20 ms 2048 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 42 ms 2424 KB Output is correct
2 Correct 37 ms 2552 KB Output is correct