답안 #166423

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
166423 2019-12-02T10:41:22 Z tincamatei Cipele (COCI18_cipele) C++14
0 / 90
985 ms 112092 KB
#include <bits/stdc++.h>

using namespace std;

vector<int> v1, v2;

bool check(int T) {
  int j = 0;
  for(int i = 0; i < v1.size(); ++i) {
    while(j < v2.size() && abs(v2[j] - v1[i]) > T)
      ++j;
    printf("%d[%d] <-> %d[%d]\n", v1[i], i, v2[j], j);
    if(j == v2.size())
      return false;
    ++j;
  }
  return true;
}

int main() {
  int n, m, x;
  scanf("%d%d", &n, &m);
  for(int i = 0; i < n; ++i) {
    scanf("%d", &x);
    v1.push_back(x);
  }
  for(int i = 0; i < m; ++i) {
    scanf("%d", &x);
    v2.push_back(x);
  }

  if(v1.size() > v2.size())
    v1.swap(v2);

  sort(v1.begin(), v1.end());
  sort(v2.begin(), v2.end());

  int st = -1, dr = 1000000001;

  while(dr - st > 1) {
    int mid = (st + dr) / 2;
    if(check(mid))
      dr = mid;
    else
      st = mid;
  }

  printf("%d", dr);
  return 0;
}

Compilation message

cipele.cpp: In function 'bool check(int)':
cipele.cpp:9:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0; i < v1.size(); ++i) {
                  ~~^~~~~~~~~~~
cipele.cpp:10:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(j < v2.size() && abs(v2[j] - v1[i]) > T)
           ~~^~~~~~~~~~~
cipele.cpp:13:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(j == v2.size())
        ~~^~~~~~~~~~~~
cipele.cpp: In function 'int main()':
cipele.cpp:22:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &n, &m);
   ~~~~~^~~~~~~~~~~~~~~~
cipele.cpp:24:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &x);
     ~~~~~^~~~~~~~~~
cipele.cpp:28:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &x);
     ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 814 ms 90460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 985 ms 112092 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 23 ms 2168 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 37 ms 3092 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 30 ms 3048 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 40 ms 3844 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 675 ms 73336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 852 ms 94444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 679 ms 75000 KB Output isn't correct
2 Halted 0 ms 0 KB -