#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define ff first
#define ss second
ll ttt;
const ll INF=1e18;
const ll MOD=1e9+7;
const ll N=100007;
ll n,m,k;
int f[N],s[N];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
// freopen("Finput.txt","r",stdin);
// freopen("Foutput.txt","w",stdout);
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=MOD;
int ansmsk=0;
for(int msk=0;msk<(1<<n);msk++){
int curmax=0;
for(int j=0;j<m;j++){
int cur=MOD;
for(int i=0;i<n;i++){
if(((msk&(1<<i))&&s[i]<f[j])||
((!(msk&(1<<i)))&&s[i]>f[j])){
cur=min(cur,abs(s[i]-f[j]));
}
}
curmax=max(curmax, cur);
}
if(ans>curmax){
ans=curmax;
ansmsk=msk;
}
}
if(ans==MOD){
cout<<-1<<endl;
return 0;
}
cout<<ans<<endl;
for(int i=0;i<n;i++){
if(ansmsk&(1<<i)){
cout<<"R";
}
else{
cout<<"L";
}
}
cout<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Correct |
0 ms |
348 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Correct |
2 |
Incorrect |
5 ms |
600 KB |
User solution is worse than jury's solution |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Execution timed out |
2039 ms |
600 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Correct |
0 ms |
348 KB |
Correct |
3 |
Incorrect |
6 ms |
348 KB |
User solution is worse than jury's solution |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Execution timed out |
2086 ms |
860 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Correct |
0 ms |
348 KB |
Correct |
3 |
Incorrect |
5 ms |
600 KB |
User solution is worse than jury's solution |
4 |
Halted |
0 ms |
0 KB |
- |