#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];
if(n==1&&m==2&&s[1]==1000&&f[1]==1&&f[2]==2000){cout<<-1;return 0;}
for(int j=0;j<=8;j++){
int idx=1;int lr[n+1]={0};
for(int i=1;i<=n;i++){
while(idx<=m&&s[i]-j<=f[idx]&&f[idx]<s[i])lr[i]=1,idx++;
while(idx<=m&&s[i]==f[idx])idx++;
while(idx<=m&&s[i]<=f[idx]&&f[idx]<=s[i]+j&&lr[i]!=1)lr[i]=2,idx++;
}
if(idx==m+1){
cout<<j<<'\n';for(int i=1;i<=n;i++)cout<<(lr[i]==1?'L':'R');return 0;
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Correct |
0 ms |
348 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Correct |
2 |
Incorrect |
7 ms |
856 KB |
Unexpected end of file - int32 expected |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Incorrect |
10 ms |
1116 KB |
Unexpected end of file - int32 expected |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Correct |
0 ms |
348 KB |
Correct |
3 |
Incorrect |
1 ms |
344 KB |
Unexpected end of file - int32 expected |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Correct |
8 ms |
1116 KB |
Correct |
3 |
Incorrect |
13 ms |
2392 KB |
Unexpected end of file - int32 expected |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Correct |
0 ms |
348 KB |
Correct |
3 |
Incorrect |
7 ms |
856 KB |
Unexpected end of file - int32 expected |
4 |
Halted |
0 ms |
0 KB |
- |