#include <bits/stdc++.h>
#define int long long
#define endl "\n"
using namespace std;
signed main(){
int n,m;
cin>>n>>m;
set<int>nums;
vector<int>sprinklers(n);
vector<int>flowers(m);
for(int i=0;i<n;i++)cin>>sprinklers[i];
for(int i=0;i<m;i++)cin>>flowers[i];
for(int i=0;i<n;i++)nums.insert(sprinklers[i]);
for(int i=0;i<m;i++)nums.insert(flowers[i]);
int maxdistance=-1;
bool flag=false;
auto it1=nums.begin();
auto it2=nums.end();it2--;
if(n==1){
if((sprinklers[0]!=(*it1)&&sprinklers[0]!=(*it2))){
cout<<-1<<endl;
flag=true;
}
}
if(!flag){
for(int i=0;i<m;i++){
int mindistance=INT_MAX;
for(int j=0;j<n;j++){
mindistance=min(mindistance,abs(sprinklers[j]-flowers[i]));
}
maxdistance=max(maxdistance,mindistance);
}
cout<<maxdistance<<endl;
if(n==1){
if(sprinklers[0]==(*it1)){
cout<<'R'<<endl;
}else{
cout<<'L'<<endl;
}
}else{
for(int i=0;i<n;i++){
if(n%3==0)cout<<'L';
else cout<<'R';
}
cout<<endl;
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
User solution is incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Correct |
2 |
Correct |
32 ms |
3908 KB |
Correct |
3 |
Correct |
0 ms |
348 KB |
Correct |
4 |
Correct |
37 ms |
5836 KB |
Correct |
5 |
Correct |
39 ms |
5752 KB |
Correct |
6 |
Correct |
0 ms |
348 KB |
Correct |
7 |
Correct |
0 ms |
348 KB |
Correct |
8 |
Correct |
7 ms |
1372 KB |
Correct |
9 |
Correct |
0 ms |
348 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
User solution is incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
User solution is incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
User solution is incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
User solution is incorrect |
2 |
Halted |
0 ms |
0 KB |
- |