#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Correct |
0 ms |
348 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Correct |
2 |
Incorrect |
5 ms |
1392 KB |
User solution is worse than jury's solution |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Execution timed out |
2061 ms |
604 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Correct |
0 ms |
348 KB |
Correct |
3 |
Incorrect |
5 ms |
344 KB |
User solution is worse than jury's solution |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Execution timed out |
2019 ms |
856 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Correct |
0 ms |
348 KB |
Correct |
3 |
Incorrect |
5 ms |
1392 KB |
User solution is worse than jury's solution |
4 |
Halted |
0 ms |
0 KB |
- |