Submission #82436

#TimeUsernameProblemLanguageResultExecution timeMemory
82436diegogrcCipele (COCI18_cipele)C++17
90 / 90
54 ms11484 KiB
// Copyright © 2018 Diego Garcia Rodriguez del Campo. All rights reserved. #include<bits/stdc++.h> #define MAX 200005 #define INF 1e10 #define optimiza_io cin.tie(0); ios_base::sync_with_stdio(0); using namespace std; typedef long long i64; i64 N, M; i64 a[MAX]; i64 b[MAX]; bool canDo( i64 x ) { i64 cnt = 1; for( i64 i = 1; i <= N; i ++ ) { while( cnt <= M && abs( b[cnt] - a[i] ) > x ) cnt++; if( cnt > M ) return false; cnt++; } return true; } int main() { optimiza_io cin >> N >> M; if( N < M ) { for( i64 i = 1; i <= N; i ++ ) cin >> a[i]; for( i64 i = 1; i <= M; i ++ ) cin >> b[i]; } else { for( i64 i = 1; i <= N; i ++ ) cin >> b[i]; for( i64 i = 1; i <= M; i ++ ) cin >> a[i]; swap( N , M ); } sort( a + 1 , a + N + 1 ); sort( b + 1 , b + M + 1 ); i64 ini = 0; i64 fin = INF; while( ini < fin ) { i64 mid = ( ini + fin ) / 2; if( canDo( mid ) ) fin = mid; else ini = mid + 1; } cout << ini << "\n"; return 0; }
#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...