Submission #1069906

#TimeUsernameProblemLanguageResultExecution timeMemory
1069906vjudge1Sprinklers (CEOI24_sprinklers)C++17
26 / 100
2041 ms3552 KiB
#include <bits/stdc++.h> #define div / #define ll long long #define fore(i, l, r) for(int i=int(l); i<int(r); i++) #define sz(a) int((a).size()) using namespace std; const int INF = 1e9; const int MX = 5e5 + 23; const int MOD = 1000000007; const int MAX_N = 5e5+23; const int N = 1e6; void solve() { int n,m; cin >> n >> m; int s[n],f[m],ans=INF,ok=1; string ansString; fore(i,0,n) cin >> s[i]; fore(i,0,m) cin >> f[i]; vector<int>v; for(int i=0; i<n; i+=3) { if(s[i] != s[i+1] or s[i+1] != s[i+2]) ok=0; v.push_back(s[i]); } if(ok) { ans=0; sort(v.begin(), v.end()); fore(i,0,m) { int tmp=INF; auto itr = lower_bound(v.begin(), v.end(), f[i]); tmp = min(tmp, abs(f[i]-(*itr))); if(itr - v.begin() > 0) { itr--; tmp = min(tmp,abs(f[i]-(*itr))); } ans = max(ans,tmp); } cout << ans << endl; fore(i,0,n div 3) cout << "RRL"; cout << endl; return; } fore(p,0,1024) { string tmp; fore(j,0,n) { tmp+='R'; if((1 << j) & p) tmp[j] = 'L'; } int k=0; fore(i,0,m) { int tmpK=INF; fore(j,0,n) { if(tmp[j] == 'L' and f[i] <= s[j]) tmpK=min(tmpK,abs(s[j]-f[i])); if(tmp[j] == 'R' and f[i] >= s[j]) tmpK=min(tmpK,abs(s[j]-f[i])); } k = max(k,tmpK); } if(k < ans) { ans = k; ansString = tmp; } } if(ans == INF) cout << -1 << endl; else cout << ans << endl << ansString << endl; } int main() { ios::sync_with_stdio(false); 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...