Submission #158776

# Submission time Handle Problem Language Result Execution time Memory
158776 2019-10-18T17:53:50 Z a_player Cipele (COCI18_cipele) C++14
27 / 90
158 ms 1656 KB
#include <bits/stdc++.h>

using namespace std;

int N,M;
int r[200001];
int 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){
      int 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;}
    int 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 128 ms 1656 KB Output is correct
2 Correct 156 ms 1576 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 158 ms 1584 KB Output is correct
2 Correct 157 ms 1520 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 10 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 380 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 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 127 ms 1300 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 140 ms 1372 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 124 ms 1148 KB Output isn't correct
2 Halted 0 ms 0 KB -