Submission #1069980

#TimeUsernameProblemLanguageResultExecution timeMemory
1069980vjudge1Sprinklers (CEOI24_sprinklers)C++17
3 / 100
10 ms1236 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]; if(n == 1) { if(f[0] < s[0] && f[m-1] > s[0]) { cout << -1 << endl; return; } cout << max(abs(f[0]-s[0]), abs(f[m-1]-s[0])) << endl; if(f[0] < s[0]) cout << "L" << endl; else cout << "R" << endl; } else if(n <= 10 && m <= 1000) { string ans = ""; int cur = -1; for(int i=0; i<(1LL<<n); ++i) { string tmp = ""; int cnt = 0; for(int j=0; j<n; ++j) { if((1LL<<j)&i) tmp += "R"; else tmp += "L"; } for(int j=0; j<m; ++j) { bool found = 0; int tmp2 = 0; for(int k=0; k<n; ++k) { if(s[k] >= f[j] && tmp[k] == 'L') { tmp2 = max(tmp2, s[k] - f[j]); found = 1; break; } } for(int k=n-1; k>=0; --k) { if(s[k] <= f[j] && tmp[k] == 'R') { tmp2 = max(tmp2, f[j] - s[k]); found = 1; break; } } if(!found) { cnt = -1; break; } else cnt = max(cnt, tmp2); } if(cnt != -1) { if(cur == -1 or cnt < cur) { cur = cnt; ans = tmp; } } } cout << cur << endl << ans << 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...