This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
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;
if(it!=spr.end())
dif=max(dif,abs(*it-flo[i]));
if(it!=spr.begin())
{
it--;
dif=max(dif,abs(*it-flo[i]));
}
}
cout<<dif<<endl;
for(int i=0;i<n;i+=3)
{
cout<<"LRR";
}
;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |