#include <bits/stdc++.h>
#define MAXN 100007
using namespace std;
string res;
bool bt[MAXN];
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;
if(i!=n-1 && f[d]>=s[i+1]-k< && bt[i])
{
res+="RL";
while(d<m && f[d]<=s[i]+k) d++;
i++;
continue;
}
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 d=-1;
for(int i=0;i<m;i++) {
while(d<n-1 && s[d+1]<=f[i]) d++;
if(d>=0 && s[d]!=f[i]) bt[d]=true;
}
int ans=binarna(0,1000000000);
if(!check(ans)) {
cout<<-1;
return 0;
}
cout<<ans<<endl<<res<<endl;
}
Compilation message
Main.cpp: In function 'bool check(int)':
Main.cpp:17:40: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
17 | if(i!=n-1 && f[d]>=s[i+1]-k< && bt[i])
| ~~~~~~~~~~~~~~^~~~~~~
Main.cpp:17:30: warning: comparisons like 'X<=Y<=Z' do not have their mathematical meaning [-Wparentheses]
17 | if(i!=n-1 && f[d]>=s[i+1]-k< && bt[i])
| ~~~~^~~~~~~~~~
Main.cpp:17:47: error: expected ')' before '[' token
17 | if(i!=n-1 && f[d]>=s[i+1]-k< && bt[i])
| ~ ^
| )
Main.cpp:17:45: error: label 'bt' used but not defined
17 | if(i!=n-1 && f[d]>=s[i+1]-k< && bt[i])
| ^~