#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define ub(a,b) upper_bound(a.begin(),a.end(),b)-a.begin();
#define lb(a,b) lower_bound(a.begin(),a.end(),b)-a.begin();
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define sz(x) x.size()
#define T pair<double,string>
using namespace std;
const int mxn=2e5+5;
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);
int n,m;cin>>n>>m;
ll s[n+1],f[m+1];
for(int i=1;i<=n;i++)cin>>s[i];
for(int i=1;i<=m;i++)cin>>f[i];
ll l=0,r=1e12+1;
int lr[n+1]={0};
while(l<r){
ll k=(l+r)>>1;
int idx=1;memset(lr,0,sizeof lr);
for(int i=1;i<=n;i++){
while(idx<=m&&s[i]-k<=f[idx]&&f[idx]<s[i])idx++,lr[i]=1;
while(f[idx]==s[i])idx++;
while(idx<=m&&s[i]<=f[idx]&&f[idx]<=s[i]+k&&lr[i]!=1)idx++,lr[i]=2;
}if(idx!=m+1)l=k+1;
else r=k;
}if(l==1e12+1){cout<<-1;return 0;}
memset(lr,0,sizeof lr);int idx=1;
for(int i=1;i<=n;i++){
lr[i]=2;
while(idx<=m&&s[i]-l<=f[idx]&&f[idx]<s[i])idx++,lr[i]=1;
while(idx<=m&&s[i]<=f[idx]&&f[idx]<=s[i]+l&&lr[i]!=1)idx++,lr[i]=2;
if(idx==m+1&&!lr[i])lr[i]=2;
}cout<<l<<'\n';
for(int i=1;i<=n;i++)cout<<(lr[i]==1?"L":"R");
}
Compilation message
Main.cpp:36:2: error: extended character is not valid in an identifier
36 | for(int i=1;i<=n;i++){
| ^
Main.cpp:36:5: error: extended character is not valid in an identifier
36 | for(int i=1;i<=n;i++){
| ^
Main.cpp:37:2: error: extended character is not valid in an identifier
37 | lr[i]=2;
| ^
Main.cpp:37:5: error: extended character is not valid in an identifier
37 | lr[i]=2;
| ^
Main.cpp:37:8: error: extended character is not valid in an identifier
37 | lr[i]=2;
| ^
Main.cpp:38:2: error: extended character is not valid in an identifier
38 | while(idx<=m&&s[i]-l<=f[idx]&&f[idx]<s[i])idx++,lr[i]=1;
| ^
Main.cpp:38:5: error: extended character is not valid in an identifier
38 | while(idx<=m&&s[i]-l<=f[idx]&&f[idx]<s[i])idx++,lr[i]=1;
| ^
Main.cpp:38:8: error: extended character is not valid in an identifier
38 | while(idx<=m&&s[i]-l<=f[idx]&&f[idx]<s[i])idx++,lr[i]=1;
| ^
Main.cpp:38:11: error: extended character is not valid in an identifier
38 | while(idx<=m&&s[i]-l<=f[idx]&&f[idx]<s[i])idx++,lr[i]=1;
| ^
Main.cpp: In function 'int main()':
Main.cpp:36:2: error: '\U000000a0' was not declared in this scope
36 | for(int i=1;i<=n;i++){
| ^
Main.cpp:36:19: error: 'i' was not declared in this scope
36 | for(int i=1;i<=n;i++){
| ^
Main.cpp:35:32: warning: unused variable 'idx' [-Wunused-variable]
35 | memset(lr,0,sizeof lr);int idx=1;
| ^~~