Submission #1100540

#TimeUsernameProblemLanguageResultExecution timeMemory
1100540crafticatSprinklers (CEOI24_sprinklers)C++17
9 / 100
965 ms12992 KiB
#include <bits/stdc++.h> using namespace std; template<typename T> using V = vector<T>; using vi = V<int>; using pi = pair<int,int>; vi water, flowers; V<bool> types; constexpr int inf = 1e9 + 7; bool ok(int r) { int minP = -1; int nextR = -1; multiset<pi> data; for (auto x : water) data.insert({x, -1}); for (auto x : flowers) data.insert({x, 0}); for (auto [a,b] : data) { if (b == -1) { if (minP == -1) { nextR = max(nextR, a + r); types.push_back(true); } else { nextR = max(nextR, a); if (minP < a - r) return false; else minP = -1; types.push_back(false); } } else { if (minP == -1 && a > nextR) minP = a; } } return minP == -1; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n, m; cin >> n >> m; water.resize(n); flowers.resize(m); for (int i = 0; i < n; ++i) { cin >> water[i]; } for (int i = 0; i < m; ++i) { cin >> flowers[i]; } int l = 0, r = inf; // Last true while (r > l) { int mid = l + (r - l) / 2; if (ok(mid)) { r = mid; } else l = mid + 1; } types.clear(); ok(l); if (l == inf) { cout << -1; return 0; } if (l == 0) exit(5); cout << l << "\n"; for (auto x : types) { cout << (x ? "R" : "L"); } return 0; }
#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...