Submission #85387

#TimeUsernameProblemLanguageResultExecution timeMemory
85387DiegoGarciaCipele (COCI18_cipele)C++11
0 / 90
1085 ms6180 KiB
#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)

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]);
                              ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...