#include <bits/stdc++.h>
#define div /
#define ll long long
#define fore(i, l, r) for(int i=int(l); i<int(r); i++)
#define sz(a) int((a).size())
using namespace std;
const int INF = 1e9;
const int MX = 5e5 + 23;
const int MOD = 1000000007;
const int MAX_N = 5e5+23;
const int N = 1e6;
void solve() {
int n,m;
cin >> n >> m;
int s[n],f[m],odg=1e6;
string sOdg="";
fore(i,0,n)
cin >> s[i];
fore(i,0,m)
cin >> f[i];
fore(i,0,2048) {
string ans;
fore(j,0,n) {
if((1 << j) & i)
ans+='L';
else
ans+='R';
}
int Ans=0;
fore(j,0,m) {
int cnt=1e6;
fore(k,0,n) {
if(ans[k] == 'L' and s[k] >= f[j])
cnt=min(cnt,abs(s[k]-f[j]));
else if(ans[k] == 'R' and s[k] <= f[j])
cnt=min(cnt,abs(s[k]-f[j]));
}
Ans=max(Ans,cnt);
if(cnt == 1e6)
break;
}
odg=min(odg,Ans);
if(Ans == odg)
sOdg = ans;
}
if(odg == 1e6) {
cout << -1 << endl;
return;
}
cout << odg << endl << sOdg << endl;
}
int main() {
ios::sync_with_stdio(false);
int t=1;
while(t--) solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Correct |
1 ms |
360 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
360 KB |
Correct |
2 |
Correct |
122 ms |
604 KB |
Correct |
3 |
Correct |
1 ms |
348 KB |
Correct |
4 |
Correct |
7 ms |
604 KB |
Correct |
5 |
Correct |
7 ms |
604 KB |
Correct |
6 |
Incorrect |
0 ms |
348 KB |
User solution is worse than jury's solution |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Incorrect |
1707 ms |
824 KB |
User solution is worse than jury's solution |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Correct |
1 ms |
360 KB |
Correct |
3 |
Correct |
2 ms |
344 KB |
Correct |
4 |
Correct |
2 ms |
348 KB |
Correct |
5 |
Incorrect |
1 ms |
348 KB |
User solution is worse than jury's solution |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Execution timed out |
2056 ms |
880 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Correct |
1 ms |
360 KB |
Correct |
3 |
Correct |
122 ms |
604 KB |
Correct |
4 |
Correct |
1 ms |
348 KB |
Correct |
5 |
Correct |
7 ms |
604 KB |
Correct |
6 |
Correct |
7 ms |
604 KB |
Correct |
7 |
Incorrect |
0 ms |
348 KB |
User solution is worse than jury's solution |
8 |
Halted |
0 ms |
0 KB |
- |