#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],ans=INF;
string ansString;
fore(i,0,n)
cin >> s[i];
fore(i,0,m)
cin >> f[i];
fore(p,0,1024) {
string tmp;
fore(j,0,n) {
tmp+='R';
if((1 << j) & p)
tmp[j] = 'L';
}
int k=0;
fore(i,0,m) {
int tmpK=INF;
fore(j,0,n) {
if(tmp[j] == 'L' and f[i] <= s[j])
tmpK=min(tmpK,abs(s[j]-f[i]));
if(tmp[j] == 'R' and f[i] >= s[j])
tmpK=min(tmpK,abs(s[j]-f[i]));
}
k = max(k,tmpK);
}
if(k < ans) {
ans = k;
ansString = tmp;
}
}
if(ans == INF)
cout << -1 << endl;
else
cout << ans << endl << ansString << endl;
}
int main() {
ios::sync_with_stdio(false);
int t=1;
while(t--) solve();
}
# |
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 |
Correct |
162 ms |
604 KB |
Correct |
3 |
Correct |
0 ms |
344 KB |
Correct |
4 |
Correct |
171 ms |
604 KB |
Correct |
5 |
Correct |
177 ms |
816 KB |
Correct |
6 |
Correct |
0 ms |
348 KB |
Correct |
7 |
Correct |
0 ms |
348 KB |
Correct |
8 |
Correct |
37 ms |
348 KB |
Correct |
9 |
Correct |
0 ms |
348 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Execution timed out |
2065 ms |
604 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 |
Correct |
8 ms |
344 KB |
Correct |
4 |
Correct |
4 ms |
344 KB |
Correct |
5 |
Correct |
13 ms |
348 KB |
Correct |
6 |
Correct |
13 ms |
348 KB |
Correct |
7 |
Correct |
1 ms |
348 KB |
Correct |
8 |
Correct |
18 ms |
348 KB |
Correct |
9 |
Correct |
17 ms |
348 KB |
Correct |
10 |
Correct |
13 ms |
344 KB |
Correct |
11 |
Correct |
2 ms |
348 KB |
Correct |
12 |
Correct |
13 ms |
468 KB |
Correct |
13 |
Correct |
13 ms |
344 KB |
Correct |
14 |
Correct |
4 ms |
344 KB |
Correct |
15 |
Correct |
9 ms |
344 KB |
Correct |
16 |
Correct |
9 ms |
456 KB |
Correct |
17 |
Correct |
9 ms |
456 KB |
Correct |
18 |
Correct |
8 ms |
456 KB |
Correct |
19 |
Correct |
3 ms |
348 KB |
Correct |
20 |
Correct |
3 ms |
348 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Execution timed out |
2025 ms |
856 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 |
Correct |
162 ms |
604 KB |
Correct |
4 |
Correct |
0 ms |
344 KB |
Correct |
5 |
Correct |
171 ms |
604 KB |
Correct |
6 |
Correct |
177 ms |
816 KB |
Correct |
7 |
Correct |
0 ms |
348 KB |
Correct |
8 |
Correct |
0 ms |
348 KB |
Correct |
9 |
Correct |
37 ms |
348 KB |
Correct |
10 |
Correct |
0 ms |
348 KB |
Correct |
11 |
Execution timed out |
2065 ms |
604 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |