Submission #158766

# Submission time Handle Problem Language Result Execution time Memory
158766 2019-10-18T16:42:16 Z InfiniteJest Cipele (COCI18_cipele) C++14
0 / 90
184 ms 1184 KB
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;

ifstream in("input.txt");
ofstream out("output.txt");

typedef long long ll;

int n,m;
int va[100001];
int vb[100001];

bool funz(int k){
  int indp=0;
  for(int i=0;i<m;i++){
    bool flag=0;
    for(int y=indp;y<n;y++){
      if(abs(va[i]-vb[i])<=k){
        flag=1;
        indp=y+1;
      }
    }
    if(!flag)return 0;
  }
  return 1;
}

int main(){
  cin>>n>>m;
  for(int i=0;i<n;i++)cin>>va[i];
  for(int i=0;i<m;i++)cin>>vb[i];
  sort(va,va+n);
  sort(vb,vb+m);
  if(n<m){
    swap(va,vb);
    swap(n,m);
  }

  int s=0;
  int d=1e9+4;
  int minn=1e9+4;
  while(s<=d){
    int k=(s+d)/2;
    if(funz(k)){
      minn=min(minn,k);
      d=k-1;
    }
    else{
      s=k+1;
    }
  }
  cout<<minn;



}
# Verdict Execution time Memory Grader output
1 Incorrect 129 ms 1184 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 158 ms 1144 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 1144 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 1144 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 1144 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 1144 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 1144 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 129 ms 1092 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 184 ms 1116 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 126 ms 1144 KB Output isn't correct
2 Halted 0 ms 0 KB -