Submission #1208158

#TimeUsernameProblemLanguageResultExecution timeMemory
1208158NK_Sprinklers (CEOI24_sprinklers)C++20
6 / 100
26 ms1352 KiB
// Success consists of going from failure to failure without loss of enthusiasm #include <bits/stdc++.h> using namespace std; #define nl '\n' #define sz(x) int(x.size()) #define pb push_back #define eb emplace_back using str = string; template<class T> using V = vector<T>; // template<class T> using pq = priority_queue<T, vector<T>, greater<T>>; using vs = V<str>; using vi = V<int>; int main() { cin.tie(0)->sync_with_stdio(0); int N, M; cin >> N >> M; vi A(N); for(auto& x : A) cin >> x; vi B(M); for(auto& x : B) cin >> x; auto chk = [&](int k) { str ans(N, 'L'); int i = 0, j = 0; while(1) { // find the min j s.t. you match this flower with this sprinkler if (j == N) break; while(j < N && abs(B[i] - A[j]) > k) j++; if (j == N) break; int bnd = -1; if (A[j] < B[i]) bnd = A[j] + k, ans[j] = 'R'; else bnd = A[j], ans[j] = 'L'; // cout << j << " " << ans[j] << endl; // cout << i << endl; j++; while(i < M && B[i] <= bnd) i++; if (i == M) break; } if (i != M) return str("-1"); return ans; }; int lo = 0, hi = 1e9 + 10; while(lo < hi) { int mid = (lo + hi) / 2; // cout << mid << endl; if (chk(mid) != "-1") hi = mid; else lo = mid + 1; } str ans = chk(lo); if (ans != "-1") cout << lo << nl; cout << ans << nl; exit(0-0); } // Breathe In, Breathe Out
#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...