# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
85387 | DiegoGarcia | Cipele (COCI18_cipele) | C++11 | 1085 ms | 6180 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <stdio.h>
#include <math.h>
#include <climits>
#include <algorithm>
#define ll long long
using namespace std;
const ll MAXN = 1e5 + 3;
ll n,m,L[MAXN],R[MAXN],sol[MAXN],ans=LLONG_MAX;
bool vis[MAXN];
void dfs( ll niv, ll curans )
{
if( curans >= ans ) return;
if( niv > min(n,m) ){
ans = min( ans, curans );
return;
}
for( ll i=1; i<=max(n,m); i++ )
{
if(vis[i]) continue;
sol[niv] = i;
vis[i] = true;
if( n >= m ){
if( llabs(R[niv] - L[sol[niv]]) >= ans ){
vis[i] = false;
continue;
}
dfs( niv+1, max(curans, llabs(R[niv] - L[sol[niv]]) ) );
}
else{
if( llabs(L[niv] - R[sol[niv]]) >= ans ){
vis[i] = false;
continue;
}
dfs( niv+1, max(curans, llabs(L[niv] - R[sol[niv]] ) ) );
}
vis[i] = false;
}
}
int main()
{
// O( max(n,m)! / |n-m|! * max(n,m) ) = ??
scanf("%lld %lld",&n,&m);
for( ll i=1; i<=n; i++ ) scanf("%lld",&L[i]);
for( ll i=1; i<=m; i++ ) scanf("%lld",&R[i]);
dfs( 1, -LLONG_MAX );
printf("%lld", ans);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |