Submission #312499

# Submission time Handle Problem Language Result Execution time Memory
312499 2020-10-13T14:49:49 Z monus1042 Cipele (COCI18_cipele) C++17
27 / 90
1000 ms 3196 KB
// NK
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define psf push_front
#define pof pop_front
#define mkp make_pair
#define all(x) x.begin(), x.end()
#define Bolivia_is_nice ios::sync_with_stdio(false), cin.tie(nullptr)

void solve(){
  int n,m; cin>>n>>m;
  vi a,b;
  for (int i=0; i<n; ++i){
    int x; cin>>x;
    a.pb(x);
  }
  for (int i=0; i<m; ++i){
    int x; cin>>x;
    b.pb(x);
  }

  sort(all(a)), sort(all(b));
  if (a.size() > b.size()) swap(a,b);
  int ans = 2e9;
  for (int i=0; i<=b.size() - a.size(); ++i){
    int curr = 0;
    for (int j=0; j<a.size(); ++j){
      curr = max(curr, abs(a[j] - b[j + i]));
    }
    ans=min(ans, curr);
  }
  cout<<ans<<'\n';
}

int main(){
  Bolivia_is_nice;
  int t = 1; //cin>>t;
  while(t--)
    solve();
	
  return 0;
}
/*
  ~/.emacs
*/

Compilation message

cipele.cpp: In function 'void solve()':
cipele.cpp:33:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |   for (int i=0; i<=b.size() - a.size(); ++i){
      |                 ~^~~~~~~~~~~~~~~~~~~~~
cipele.cpp:35:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     for (int j=0; j<a.size(); ++j){
      |                   ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 26 ms 3068 KB Output is correct
2 Correct 40 ms 3196 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 42 ms 3188 KB Output is correct
2 Correct 41 ms 3188 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 2 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1059 ms 2812 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 957 ms 2940 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1090 ms 2804 KB Time limit exceeded
2 Halted 0 ms 0 KB -