제출 #713002

#제출 시각아이디문제언어결과실행 시간메모리
713002tamyteSwimming competition (LMIO18_plaukimo_varzybos)C++14
0 / 100
1 ms320 KiB
#include <bits/stdc++.h> using namespace std; #define sz(x) (int)(x).size() void setIO(string name = "") { cin.tie(0)->sync_with_stdio(0); // see /general/fast-io if (sz(name)) { freopen((name + ".in").c_str(), "r", stdin); // see /general/input-output freopen((name + ".out").c_str(), "w", stdout); } } /*----------------------------------*/ bool ok(int max_diff, vector<int>& arr, int left, int right) { // cout << max_diff << "\n"; for (int i = 0; i < arr.size() - left; ++i) { if (arr[i + left - 1] - arr[i] > max_diff) return false; int j = left + i; for (; j < min(right + i, (int)arr.size()); ++j) { if (arr[j] - arr[i] > max_diff) { break; } } i = j - 1; } return true; } int main() { setIO(""); int n, a, b; cin >> n >> a >> b; vector<int> arr(n); for (auto& x : arr) cin >> x; sort(arr.begin(), arr.end()); int l = 0, r = *max_element(arr.begin(), arr.end()); while (l < r) { int m = (l + r) / 2; if (ok(m, arr, a, b)) r = m; else l = m + 1; } cout << l + 1; }

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

plaukimo_varzybos.cpp: In function 'bool ok(int, std::vector<int>&, int, int)':
plaukimo_varzybos.cpp:21:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |     for (int i = 0; i < arr.size() - left; ++i) {
      |                     ~~^~~~~~~~~~~~~~~~~~~
plaukimo_varzybos.cpp: In function 'void setIO(std::string)':
plaukimo_varzybos.cpp:11:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |         freopen((name + ".in").c_str(), "r", stdin); // see /general/input-output
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
plaukimo_varzybos.cpp:12:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |         freopen((name + ".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...