QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#535521 | #9165. Petrol stations | fucious_yin# | 0 | 2ms | 4172kb | C++14 | 1.4kb | 2024-08-28 08:59:49 | 2024-08-28 08:59:55 |
answer
#include <bits/stdc++.h>
#define F(i,x,y) for(int i=(x);i<=(y);i++)
#define DF(i,x,y) for(int i=(x);i>=(y);i--)
#define ms(x,y) memset(x,y,sizeof(x))
#define SZ(x) (int)x.size()-1
#define all(x) x.begin(),x.end()
#define pb push_back
using namespace std;
typedef long long LL;
typedef unsigned long long ull;
typedef pair<int,int> pii;
template<typename T> void chkmax(T &x,T y){ x=max(x,y);}
template<typename T> void chkmin(T &x,T y){ x=min(x,y);}
template<typename T> void read(T &FF){
FF=0;int RR=1;char ch=getchar();
for(;!isdigit(ch);ch=getchar()) if(ch=='-') RR=-1;
for(;isdigit(ch);ch=getchar()) FF=(FF<<1)+(FF<<3)+ch-48;
FF*=RR;
}
const int N=100010;
int n,m,a[N],b[N];
bool dir[N];
bool chk(int mid){
int j=m;
DF(i,n,1){
if(b[j]>a[i]){
if(b[j]>a[i]+mid) return 0;
dir[i]=1;
while(j&&b[j]>=a[i]) j--;
}
else{
dir[i]=0;
while(j&&b[j]>=a[i]-mid) j--;
}
if(!j) return 1;
}
return 0;
}
int main(){
read(n),read(m);
F(i,1,n) read(a[i]);
F(i,1,m) read(b[i]);
int lo=-1,hi=1e9+5;
while(lo<hi-1){
int mid=(lo+hi)>>1;
if(chk(mid)) hi=mid;
else lo=mid;
}
if(hi==1e9+5){ puts("-1");exit(0);}
chk(hi);
printf("%d\n",hi);
F(i,1,n) if(dir[i]) putchar('R');else putchar('L');puts("");
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3844kb
input:
750 918 159 63 18 573 310 105 135 400 57 618 27 113 41 265 24 99 576 61 242 85 109 490 88 0 626 721 0 407 446 0 78 644 124 346 198 17 541 504 147 543 423 24 302 450 25 397 344 80 129 607 76 474 59 140 30 10 29 375 260 1 404 81 0 658 695 153 450 100 92 532 249 10 597 151 133 739 714 0 212 345 85 558 ...
output:
46 LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL...
result:
wrong answer 1st lines differ - expected: '0', found: '46'
Subtask #2:
score: 0
Wrong Answer
Test #13:
score: 0
Wrong Answer
time: 0ms
memory: 3776kb
input:
2 1 0 1 1
output:
0 LL
result:
wrong answer 2nd lines differ - expected: '0', found: 'LL'
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Wrong Answer
Test #17:
score: 0
Wrong Answer
time: 2ms
memory: 4172kb
input:
69973 4 44281 27162 1 15299 61302 1 19250 66379 1 45970 65938 1 23683 4445 2 62232 40589 1 37028 58991 2 58769 32024 0 41860 69672 2 14687 10058 2 7874 6780 2 60579 37047 2 739 4096 2 53137 22114 2 35060 21464 0 42597 11591 2 68051 23473 2 61458 35690 2 38719 6601 2 57406 26025 1 38192 41521 0 47941...
output:
5082 LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL...
result:
wrong answer 1st lines differ - expected: '769608', found: '5082'
Subtask #5:
score: 0
Skipped
Dependency #4:
0%
Subtask #6:
score: 0
Skipped
Dependency #1:
0%