Submission #1192388

#TimeUsernameProblemLanguageResultExecution timeMemory
1192388LucaLucaMSprinklers (CEOI24_sprinklers)C++20
9 / 100
45 ms1352 KiB
#include <iostream> #include <vector> #include <algorithm> #include <cassert> using ll = long long; #define debug(x) #x << " = " << x << '\n' int main() { #ifdef LOCAL freopen("input.txt", "r", stdin); #endif std::ios_base::sync_with_stdio(false); std::cin.tie(0); int n, m; std::cin >> n >> m; std::vector<int> s(n), f(m); for (int &x : s) { std::cin >> x; } for (int &x : f) { std::cin >> x; } std::vector<char> type(n); auto check = [&](int K) { std::vector<bool> watered(m, false); for (int i = 0, j = 0; i < n; i++) { while (j < m && watered[j]) { j++; } if (j == m) { type[i] = 'L'; continue; } if (f[j] < s[i]) { type[i] = 'L'; // ma pun spre stanga if (f[j] < s[i] - K) { return false; } while (j < m && f[j] <= s[i]) { watered[j] = true; j++; } } else { type[i] = 'R'; // ma pun spre dreapta while (j < m && f[j] <= s[i] + K) { watered[j] = true; j++; } } } return std::count(watered.begin(), watered.end(), true) == m; }; if (!check(1e9 + 1)) { std::cout << -1; return 0; } int l = 0, r = 1e9; while (l < r) { int mid = (l + r) / 2; if (check(mid)) { r = mid; } else { l = mid + 1; } } check(r); std::cout << r << '\n'; for (char c : type) { std::cout << c; } 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...