답안 #151611

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
151611 2019-09-03T19:24:48 Z MvC Cipele (COCI18_cipele) C++11
27 / 90
53 ms 2956 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<=n;j++)
		{
			if(abs(a[i]-b[j])<=x)break;
		}
		if(j==n+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 34 ms 2680 KB Output is correct
2 Correct 51 ms 2936 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 2956 KB Output is correct
2 Correct 51 ms 2872 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 4 ms 532 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 41 ms 2424 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 46 ms 2556 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 42 ms 2376 KB Output isn't correct
2 Halted 0 ms 0 KB -