Submission #158775

# Submission time Handle Problem Language Result Execution time Memory
158775 2019-10-18T17:53:16 Z a_player Cipele (COCI18_cipele) C++14
0 / 90
3 ms 548 KB
#include <bits/stdc++.h>

using namespace std;

int N,M;
int r[100];
int l[100];
int corrisp[100];
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 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 508 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 548 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 364 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -