#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pi;
typedef vector<pi> vpi;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<bool> vb;
typedef set<ll> sll;
#define IOS cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false)
#define INF(dtype) numeric_limits<dtype>::max()
#define NINF(dtype) numeric_limits<dtype>::min()
#define fi first
#define se second
typedef pair<int, vb> pib;
pib solve(int n, int m, const vi& s, const vi& f) {
vb config(n, false);
for(int i = 0; i * 3 < n; i++) {
config[3 * i] = false;
config[3 * i + 2] = true;
}
int ans = 0;
for(int i = 0; i < m; i++) {
int l = -1, r = n / 3;
while(r - l > 1) {
int mid = (l + r) >> 1;
if(s[mid * 3] <= f[i]) l = mid;
else r = mid;
}
if(l == -1) ans = max(ans, s[0] - f[i]);
else if(r == n / 3) ans = max(ans, f[i] - s[l * 3]);
else ans = max(ans, min(f[i] - s[l * 3], s[r * 3] - f[i]));
}
return {ans, config};
}
int main() {
IOS;
int n, m;
cin >> n >> m;
vi s(n, 0);
vi f(m, 0);
for(int& sv : s) cin >> sv;
for(int& fv : f) cin >> fv;
auto [ans, config] = solve(n, m, s, f);
cout << ans << "\n";
if(ans != -1) {
for(const bool& b : config) cout << (b ? 'R' : 'L');
cout << "\n";
}
cout << flush;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Incorrect |
0 ms |
348 KB |
User solution is incorrect |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
User solution is incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Correct |
9 ms |
1628 KB |
Correct |
3 |
Correct |
2 ms |
604 KB |
Correct |
4 |
Correct |
19 ms |
3156 KB |
Correct |
5 |
Correct |
20 ms |
3164 KB |
Correct |
6 |
Correct |
1 ms |
344 KB |
Correct |
7 |
Correct |
0 ms |
348 KB |
Correct |
8 |
Correct |
19 ms |
3160 KB |
Correct |
9 |
Correct |
19 ms |
3160 KB |
Correct |
10 |
Correct |
19 ms |
3164 KB |
Correct |
11 |
Correct |
9 ms |
1880 KB |
Correct |
12 |
Correct |
12 ms |
2100 KB |
Correct |
13 |
Correct |
15 ms |
2260 KB |
Correct |
14 |
Correct |
14 ms |
2396 KB |
Correct |
15 |
Correct |
15 ms |
2516 KB |
Correct |
16 |
Correct |
14 ms |
2140 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Incorrect |
0 ms |
348 KB |
User solution is incorrect |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Incorrect |
12 ms |
1880 KB |
User solution is incorrect |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Incorrect |
0 ms |
348 KB |
User solution is incorrect |
3 |
Halted |
0 ms |
0 KB |
- |