#include <bits/stdc++.h>
#define int long long
using namespace std;
void solve() {
int n, m;
cin >> n >> m;
int s[n], f[m];
for(int i=0; i<n; ++i) cin >> s[i];
for(int i=0; i<m; ++i) cin >> f[i];
for(int k=0; k<=8; ++k) {
int last = 0, L = 0, R = 0;
vector<char>ans(n, 'L');
for(int i=0; i<n; ++i) {
while(last < m && (f[last] <= L or f[last] <= R)) ++last;
if(last == m) {
cout << k << endl;
for(int i=0; i<n; ++i) cout << ans[i];
cout << endl;
return;
}
if(f[last] >= s[i]) {
ans[i] = 'R';
R = s[i] + k;
} else L = s[i];
}
}
cout << -1 << endl;
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int t = 1;
while(t--) solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Correct |
2 |
Correct |
0 ms |
348 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Correct |
2 |
Incorrect |
7 ms |
860 KB |
User solution is worse than jury's solution |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Correct |
2 |
Incorrect |
9 ms |
1116 KB |
User solution is worse than jury's solution |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Correct |
2 |
Correct |
0 ms |
348 KB |
Correct |
3 |
Incorrect |
0 ms |
348 KB |
User solution is worse than jury's solution |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Correct |
2 |
Incorrect |
9 ms |
1112 KB |
User solution is worse than jury's solution |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Correct |
2 |
Correct |
0 ms |
348 KB |
Correct |
3 |
Incorrect |
7 ms |
860 KB |
User solution is worse than jury's solution |
4 |
Halted |
0 ms |
0 KB |
- |