Submission #779114

# Submission time Handle Problem Language Result Execution time Memory
779114 2023-07-11T08:00:40 Z vjudge1 Cipele (COCI18_cipele) C++17
27 / 90
1000 ms 2012 KB
#include<bits/stdc++.h>
using namespace std;
#define lalala ios_base::sync_with_stdio(false);cin.tie(NULL);
//#define endl "\n"
#define int long long int
#define pb push_back

signed main(){
	lalala;
	int n,m;cin>>n>>m;

	int sa[n],sol[m];
	for(int i=0;i<n;i++)cin>>sa[i];
	for(int i=0;i<m;i++)cin>>sol[i];
	sort(sa,sa+n);
	sort(sol,sol+m);
	if(n==m){
		int mx=0;
		for(int i=0;i<n;i++)mx=max(mx,abs(sa[i]-sol[i]));
		cout<<mx<<endl;
		return 0;
	}
	if(n<m){
		int mn=1000'000'000'000;
		for(int i=0;i<m-n+1;i++){
			int mx=0;
			for(int j=i;j<i+n;j++){
				mx=max(mx,abs(sa[j-i]-sol[j]));
			}
			if(mx>mn)break;
			mn=mx;
		}
		cout<<mn<<endl;
	}
	else{
		int mn=1000'000'000'000;
		for(int i=0;i<n-m+1;i++){
			int mx=0;
			for(int j=i;j<i+m;j++){
				mx=max(mx,abs(sa[j]-sol[j-i]));
			}
			if(mx>mn)break;
			mn=mx;
		}
		cout<<mn<<endl;
		return 0;
	}

}
# Verdict Execution time Memory Grader output
1 Correct 16 ms 1876 KB Output is correct
2 Correct 28 ms 1996 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 1876 KB Output is correct
2 Correct 28 ms 2012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1057 ms 1492 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 728 ms 1680 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1051 ms 1492 KB Time limit exceeded
2 Halted 0 ms 0 KB -