Submission #1070181

#TimeUsernameProblemLanguageResultExecution timeMemory
1070181vjudge1Sprinklers (CEOI24_sprinklers)C++17
0 / 100
15 ms3208 KiB
#include <bits/stdc++.h> #define int long long using namespace std; void solve() { int n, m; cin >> n >> m; int s[n], f[m]; for(int i=0; i<n; ++i) cin >> s[i]; for(int i=0; i<m; ++i) cin >> f[i]; for(int k=0; k<=8; ++k) { bool imp = 0; int last = 0, R = -1, L = -1; vector<char>ans(n, 'L'); for(int i=0; i<m; ++i) { if(f[i] <= R or L >= f[i]) continue; if(last == n) { imp = 1; break; } while(last<n && s[last]+k < f[i]) ++last; if(last == n) { imp = 1; break; } if(s[last] <= f[i]) { ans[last] = 'R'; R = s[last] + k; } else if((s[last] - k) > f[i]) { imp = 1; break; } else L = s[last]; ++last; } if(imp) continue; cout << k << endl; for(int i=0; i<n; ++i) cout << ans[i]; cout << endl; return; } cout << -1 << endl; } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t = 1; while(t--) solve(); }
#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...