답안 #151599

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
151599 2019-09-03T16:13:53 Z MvC Cipele (COCI18_cipele) C++11
45 / 90
135 ms 99324 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=5e3+50;
const int mod=1e9+7;
using namespace std;
int n,m,i,j,a[nmax],b[nmax],f[nmax][nmax],rs;
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);
	for(i=1;i<=n;i++)for(j=0;j<=m;j++)f[i][j]=1e9;
	f[0][0]=0;
	rs=1e9;
	for(i=1;i<=n;i++)
	{
		for(j=i;j<=m;j++)
		{
			f[i][j]=f[i][j-1];
			f[i][j]=min(f[i][j],max(f[i-1][j-1],abs(b[j]-a[i])));
		}
	}
	for(i=n;i<=m;i++)rs=min(rs,f[n][i]);
	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 Runtime error 10 ms 888 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 10 ms 1016 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 35064 KB Output is correct
2 Correct 135 ms 99220 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 2424 KB Output is correct
2 Correct 129 ms 99324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 100 ms 69648 KB Output is correct
2 Correct 131 ms 99260 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 100 ms 69624 KB Output is correct
2 Correct 130 ms 99304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 122 ms 89436 KB Output is correct
2 Correct 129 ms 99320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 10 ms 1012 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 10 ms 932 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 10 ms 888 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -