답안 #85387

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
85387 2018-11-19T15:15:25 Z DiegoGarcia Cipele (COCI18_cipele) C++11
0 / 90
1000 ms 6180 KB
#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

cipele.cpp: In function 'int main()':
cipele.cpp:42:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld %lld",&n,&m);
     ~~~~~^~~~~~~~~~~~~~~~~~~
cipele.cpp:43:35: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for( ll i=1; i<=n; i++ ) scanf("%lld",&L[i]);
                              ~~~~~^~~~~~~~~~~~~~
cipele.cpp:44:35: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for( ll i=1; i<=m; i++ ) scanf("%lld",&R[i]);
                              ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1075 ms 6148 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1070 ms 6148 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 6148 KB Output is correct
2 Execution timed out 1076 ms 6148 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1083 ms 6148 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1077 ms 6148 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1085 ms 6148 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1066 ms 6148 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1077 ms 6148 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1083 ms 6180 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1080 ms 6180 KB Time limit exceeded
2 Halted 0 ms 0 KB -