Submission #158777

# Submission time Handle Problem Language Result Execution time Memory
158777 2019-10-18T17:54:56 Z a_player Cipele (COCI18_cipele) C++14
27 / 90
157 ms 2348 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int N,M;
ll r[200001];
ll l[200001];
int corrisp[200001];
int main() {
  cin>>N>>M;
  for(int i=0;i<N;i++)cin>>r[i];
  for(int i=0;i<M;i++)cin>>l[i];
  if(N>M){
    swap(N,M);
    swap(r,l);
  }
  sort(r,r+N);
  sort(l,l+M);
  int a=0,b=M-1;
  for(int i=0;i<N/2;i++){
    while(a<M-1){
      if(abs(l[a]-r[i])>abs(l[a+1]-r[i])&&b-a-1>N-2*i-2)a++;
      else break;
    }
    while(b>0){
      if(abs(l[b]-r[N-i-1])>abs(l[b-1]-r[N-i-1])&&b-a-1>N-2*i-2)b--;
      else break;
    }
    corrisp[i]=a;
    corrisp[N-i-1]=b;
    a++;
    b--;
  }
  if(N%2){
      ll mini=abs(l[a]-r[N/2]);
    int pos=a;
    for(int i=a+1;i<=b;i++){
      if(mini>abs(l[i]-r[N/2])){
        mini=abs(l[i]-r[N/2]);
        pos=i;
      }
    }corrisp[N/2]=pos;}
    ll mini=abs(r[0]-l[corrisp[0]]);
  for(int i=1;i<N;i++)mini=max(abs(r[i]-l[corrisp[i]]),mini);
  cout<<mini;
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 138 ms 2348 KB Output is correct
2 Correct 157 ms 2308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 156 ms 2332 KB Output is correct
2 Correct 155 ms 2296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 10 ms 436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 126 ms 1784 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 141 ms 2016 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 128 ms 1788 KB Output isn't correct
2 Halted 0 ms 0 KB -