#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <math.h>
#include <bitset>
#include <cmath>
#include <vector>
#include <iomanip>
#include <random>
#include <chrono>
#include <cassert>
using namespace std;
#define ll long long
#define fr first
#define sc second
#define pb push_back
#define US freopen(".in", "r", stdin); freopen("j.out", "w", stdout);
ll gcd(ll a, ll b)
{
if (a == 0 || b == 0) {
return max(a, b);
}
if (a <= b) {
return gcd(a, b % a);
}
else {
return gcd(a % b, b);
}
}
ll lcm(ll a, ll b) {
return (a / gcd(a, b)) * b;
}
const int N = 200005;
const ll oo = 100000000000000000, MOD = 1000000007;
int n, m;
ll f[N], s[N];
void solve() {
cin >> n >> m;
for (int i = 1; i <= n; ++i) {
cin >> s[i];
}
for (int i = 1; i <= m; ++i) {
cin >> f[i];
}
ll ans = 0;
for (int i = 1; i <= m; ++i) {
int l = 1, r = n;
ll distl = oo, distr = oo;
while (l <= r) {
int mid = (l + r) / 2;
if (s[mid] <= f[i]) {
distl = f[i] - s[mid];
l = mid + 1;
}
else {
r = mid - 1;
}
}
l = 0, r = n;
while (l <= r) {
int mid = (l + r) / 2;
if (s[mid] >= f[i]) {
distr = s[mid] - f[i];
r = mid - 1;
}
else {
l = mid + 1;
}
}
ans = max(ans, min(distl, distr));
}
if (ans == oo) {
cout << -1 << endl;
return;
}
cout << ans << endl;
for (int i = 1; i <= n; i += 3) {
cout << "LRR";
}
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
//US
int tt = 1;
//cin >> tt;
while (tt--) {
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Correct |
2 |
Incorrect |
0 ms |
2396 KB |
Incorrect string length |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
2396 KB |
Incorrect string length |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Correct |
2 |
Correct |
8 ms |
3044 KB |
Correct |
3 |
Correct |
2 ms |
2652 KB |
Correct |
4 |
Correct |
17 ms |
4596 KB |
Correct |
5 |
Correct |
21 ms |
4696 KB |
Correct |
6 |
Correct |
0 ms |
2396 KB |
Correct |
7 |
Correct |
0 ms |
2396 KB |
Correct |
8 |
Incorrect |
15 ms |
4752 KB |
User solution is incorrect |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Correct |
2 |
Incorrect |
0 ms |
2396 KB |
Incorrect string length |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Correct |
2 |
Incorrect |
10 ms |
3160 KB |
Incorrect string length |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Correct |
2 |
Incorrect |
0 ms |
2396 KB |
Incorrect string length |
3 |
Halted |
0 ms |
0 KB |
- |