제출 #63557

#제출 시각아이디문제언어결과실행 시간메모리
63557yu0524구경하기 (JOI13_watching)C++14
0 / 100
1083 ms848 KiB
#include <iostream> #include <algorithm> #include <vector> #include <string.h> #include <queue> using namespace std; typedef long long ll; int N, p, q, a; vector<ll> arr; int func(ll w, int cur = 0, int sw = p, int bw = q) { if (sw <= 0 && bw <= 0) return 0; if (cur >= arr.size()) return 1; bool chk1 = 0, chk2 = 0; for (int i = cur+1; i < arr.size(); ++i) { if (arr[i] - arr[cur] + 1 > w && chk1 == 0 && sw) { chk1 = 1; if (func(w, i, sw - 1, bw)) return 1; } if (arr[i] - arr[cur] + 1 > 2 * w && chk2 == 0 && bw) { chk2 = 1; if (func(w, i, sw, bw - 1)) return 1; } } if (chk1 == 0 && sw) return 1; if (chk2 == 0 && bw) return 1; return 0; } int main() { cin.tie(NULL); ios::sync_with_stdio(false); cin >> N; cin >> p >> q; for (int i = 0; i < N; ++i) { cin >> a; arr.push_back(a); } sort(arr.begin(), arr.end()); arr.resize(distance(arr.begin(), unique(arr.begin(), arr.end()))); ll x = 1, y = 1000000000, mid, res; while (x <= y) { mid = (x + y) >> 1; if (func(mid)) { y = mid - 1; res = mid; } else { x = mid + 1; } } cout << res; }

컴파일 시 표준 에러 (stderr) 메시지

watching.cpp: In function 'int func(ll, int, int, int)':
watching.cpp:13:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if (cur >= arr.size()) return 1;
      ~~~~^~~~~~~~~~~~~
watching.cpp:15:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = cur+1; i < arr.size(); ++i) {
                      ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...