Submission #1091010

#TimeUsernameProblemLanguageResultExecution timeMemory
1091010PajarajaSprinklers (CEOI24_sprinklers)C++17
9 / 100
75 ms3428 KiB
#include <bits/stdc++.h> #define MAXN 100007 using namespace std; string res; int s[MAXN],f[MAXN],n,m; bool check(int k){ res.clear(); int d=0; for(int i=0;i<n;i++) { if(d==m) { res+='L'; continue; } if(f[d]<s[i]) { if(f[d]<s[i]-k) return false; res+='L'; while(d<m && f[d]<=s[i]) d++; continue; } if(f[d]>=s[i]){ res+='R'; while(d<m && f[d]<=s[i]+k) d++; } } if(d==m) return true; return false; } int binarna(int l,int r) { if(l==r) return l; int s=(l+r)/2; if(check(s)) return binarna(l,s); return binarna(s+1,r); } int main() { cin>>n>>m; for(int i=0;i<n;i++) cin>>s[i]; for(int i=0;i<m;i++) cin>>f[i]; int ans=binarna(1,1000000000); if(!check(ans)) { cout<<-1; return 0; } cout<<ans<<endl<<res<<endl; }
#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...