제출 #1275447

#제출 시각아이디문제언어결과실행 시간메모리
1275447chanhchuong123Cipele (COCI18_cipele)C++20
90 / 90
29 ms1212 KiB
#include<bits/stdc++.h> using namespace std; const bool multiTest = false; #define task "C" #define fi first #define se second #define MASK(i) (1LL << (i)) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define BIT(mask, i) ((mask) >> (i) & 1) template<typename T1, typename T2> bool minimize(T1 &a, T2 b) { if (a > b) a = b; else return 0; return 1; } template<typename T1, typename T2> bool maximize(T1 &a, T2 b) { if (a < b) a = b; else return 0; return 1; } const int MAX = 100010; int n, m; int l[MAX]; int r[MAX]; void process(void) { cin >> n >> m; for (int i = 1; i <= n; ++i) cin >> l[i]; for (int i = 1; i <= m; ++i) cin >> r[i]; sort(l + 1, l + 1 + n); sort(r + 1, r + 1 + m); if (n < m) { swap(l, r); swap(n, m); } int ll = -1, rr = max(l[n], r[m]); while (rr - ll > 1) { int mid = ll + rr >> 1; auto f = [&](int x) { for (int i = 1, j = 1; i <= m; ++i) { while (j <= n && l[j] < r[i] - x) ++j; if (j <= n && abs(r[i] - l[j]) <= x) { ++j; continue; } return false; } return true; }; if (f(mid)) rr = mid; else ll = mid; } cout << rr; } int main(void) { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); if (fopen(task".inp", "r")) { freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } int nTest = 1; if (multiTest) cin >> nTest; while (nTest--) { process(); } return 0; }

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

cipele.cpp: In function 'int main()':
cipele.cpp:60:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   60 |                 freopen(task".inp", "r",  stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
cipele.cpp:61:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   61 |                 freopen(task".out", "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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...