답안 #151612

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
151612 2019-09-03T19:26:00 Z MvC Cipele (COCI18_cipele) C++11
90 / 90
53 ms 2680 KB
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include<bits/stdc++.h>
//#include "boxes.h"
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<61);
const int inf=(1<<30);
const int nmax=1e5+50;
const int mod=1e9+7;
using namespace std;
int n,m,i,j,a[nmax],b[nmax],rs,l,r,mid;
int ok(int x)
{
	int i,j=1;
	for(i=1;i<=n;i++)
	{
		for(;j<=m;j++)
		{
			if(abs(a[i]-b[j])<=x)break;
		}
		if(j==m+1)return 0;
		j++;
	}
	return 1;
}
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n>>m;
	for(i=1;i<=n;i++)cin>>a[i];
	for(i=1;i<=m;i++)cin>>b[i];
	if(n>m)
	{
		swap(a,b);
		swap(n,m);
	}
	sort(a+1,a+n+1);
	sort(b+1,b+m+1);
	l=0,r=1e9,rs=1e9;
	while(l<=r)
	{
		mid=(l+r)/2;
		if(ok(mid))rs=mid,r=mid-1;
		else l=mid+1;
	}
	cout<<rs<<endl;
	return 0;
}

Compilation message

cipele.cpp:2:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("O3")
 
cipele.cpp:3:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("unroll-loops")
# 결과 실행 시간 메모리 Grader output
1 Correct 41 ms 1276 KB Output is correct
2 Correct 51 ms 1144 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 51 ms 1144 KB Output is correct
2 Correct 53 ms 1144 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 4 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 4 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 1144 KB Output is correct
2 Correct 32 ms 2172 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 1064 KB Output is correct
2 Correct 28 ms 2188 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 49 ms 1016 KB Output is correct
2 Correct 45 ms 2680 KB Output is correct