#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
int n,m;
cin>>n>>m;
vector<int> spr(n),flo(m);
for(int i=0;i<n;i++)
{
cin>>spr[i];
}
int mn=LLONG_MAX;
int mx=0;
for(int i=0;i<m;i++)
{
cin>>flo[i];
mn=min(mn,flo[i]);
mx=max(mx,flo[i]);
}
if(spr[0]>=mx&&n==1)
{
cout<<spr[0]-mn;
cout<<endl;
cout<<"L";
}
else if(spr[0]<=mn&&n==1)
{
cout<<mx-spr[0];
cout<<endl;
cout<<"R";
}
else if(n==1){
cout<<"-1";
return 0;
}
if(n==1)
return 0;
int dif=0;
for(int i=0;i<m;i++)
{
auto it= lower_bound(spr.begin(),spr.end(),flo[i]);
if(*it==flo[i])
continue;
int temp1=LLONG_MAX;
int temp2=LLONG_MAX;
if(it!=spr.end()){
temp1=abs(*it-flo[i]);
}
if(it!=spr.begin())
{
int x=it-spr.begin();
x--;
temp2 =abs(spr[x]-flo[i]);
}
dif=max(dif,min(temp2,temp1));
}
cout<<dif<<endl;
for(int i=0;i<n;i++)
{
if(i%3)
cout<<"R";
else
cout<<"L";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Correct |
2 |
Correct |
1 ms |
336 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Correct |
2 |
Correct |
22 ms |
848 KB |
Correct |
3 |
Correct |
1 ms |
336 KB |
Correct |
4 |
Correct |
25 ms |
1220 KB |
Correct |
5 |
Correct |
33 ms |
1104 KB |
Correct |
6 |
Correct |
1 ms |
336 KB |
Correct |
7 |
Correct |
1 ms |
336 KB |
Correct |
8 |
Correct |
5 ms |
592 KB |
Correct |
9 |
Correct |
1 ms |
336 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Correct |
2 |
Correct |
27 ms |
1104 KB |
Correct |
3 |
Correct |
5 ms |
592 KB |
Correct |
4 |
Correct |
61 ms |
4028 KB |
Correct |
5 |
Correct |
60 ms |
4020 KB |
Correct |
6 |
Correct |
1 ms |
336 KB |
Correct |
7 |
Correct |
1 ms |
336 KB |
Correct |
8 |
Correct |
57 ms |
3904 KB |
Correct |
9 |
Correct |
55 ms |
3912 KB |
Correct |
10 |
Correct |
58 ms |
3920 KB |
Correct |
11 |
Correct |
38 ms |
2244 KB |
Correct |
12 |
Correct |
37 ms |
2660 KB |
Correct |
13 |
Correct |
35 ms |
2896 KB |
Correct |
14 |
Correct |
39 ms |
2888 KB |
Correct |
15 |
Correct |
45 ms |
3156 KB |
Correct |
16 |
Correct |
34 ms |
2748 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Correct |
2 |
Correct |
1 ms |
336 KB |
Correct |
3 |
Incorrect |
2 ms |
336 KB |
User solution is incorrect |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Correct |
2 |
Incorrect |
31 ms |
1272 KB |
User solution is incorrect |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Correct |
2 |
Correct |
1 ms |
336 KB |
Correct |
3 |
Correct |
22 ms |
848 KB |
Correct |
4 |
Correct |
1 ms |
336 KB |
Correct |
5 |
Correct |
25 ms |
1220 KB |
Correct |
6 |
Correct |
33 ms |
1104 KB |
Correct |
7 |
Correct |
1 ms |
336 KB |
Correct |
8 |
Correct |
1 ms |
336 KB |
Correct |
9 |
Correct |
5 ms |
592 KB |
Correct |
10 |
Correct |
1 ms |
336 KB |
Correct |
11 |
Correct |
27 ms |
1104 KB |
Correct |
12 |
Correct |
5 ms |
592 KB |
Correct |
13 |
Correct |
61 ms |
4028 KB |
Correct |
14 |
Correct |
60 ms |
4020 KB |
Correct |
15 |
Correct |
1 ms |
336 KB |
Correct |
16 |
Correct |
1 ms |
336 KB |
Correct |
17 |
Correct |
57 ms |
3904 KB |
Correct |
18 |
Correct |
55 ms |
3912 KB |
Correct |
19 |
Correct |
58 ms |
3920 KB |
Correct |
20 |
Correct |
38 ms |
2244 KB |
Correct |
21 |
Correct |
37 ms |
2660 KB |
Correct |
22 |
Correct |
35 ms |
2896 KB |
Correct |
23 |
Correct |
39 ms |
2888 KB |
Correct |
24 |
Correct |
45 ms |
3156 KB |
Correct |
25 |
Correct |
34 ms |
2748 KB |
Correct |
26 |
Incorrect |
2 ms |
336 KB |
User solution is incorrect |
27 |
Halted |
0 ms |
0 KB |
- |