| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1364298 | Aviansh | Sprinklers (CEOI24_sprinklers) | C++20 | 30 ms | 2172 KiB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n,m;
cin >> n >> m;
int s[n];
for(int i = 0;i<n;i++){
cin >> s[i];
}
int f[m];
for(int i = 0;i<m;i++){
cin >> f[i];
}
sort(f,f+m);
sort(s,s+n);
char ans[n];
auto check = [&] (int k){
//n sprinklers, m flowers both sorted
int ind = 0;
//default
fill(ans,ans+n,'L');
for(int i = 0;i<n;i++){
//ind is to be covered
if(ind>=m)
break;
if(abs(f[ind]-s[i])>k){
//cant be covered continue
continue;
}
//can be covered
if(f[ind]<s[i]){
//must go left
while(ind<m&&f[ind]<=s[i]){
ind++;
}
//ind reseted
}
else{
//must go right
ans[i]='R';
while(ind<m&&f[ind]<=s[i]+k){
ind++;
}
//ind reset
}
}
if(ind>=m){
return 1;
}
return 0;
};
int lo = 0;
int hi = 2e9;
while(lo<hi){
int mid = (lo+hi)/2;
if(check(mid)){
hi=mid;
}
else{
lo=mid+1;
}
}
if(lo==2e9){
cout << -1;
return 0;
}
check(lo);
cout << lo << "\n";
for(char c:ans){
cout << c;
}
return 0;
}
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
