| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1364295 | Aviansh | Sprinklers (CEOI24_sprinklers) | C++20 | 11 ms | 1080 KiB |
#include <bits/stdc++.h>
using namespace std;
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n,m;
cin >> n >> m;
int s[n];
for(int &i : s){
cin >> i;
}
int f[m];
for(int &i : f){
cin >> i;
}
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;
};
for(int i = 0;i<=10;i++){
if(check(i)){
cout << i << "\n";
for(char c : ans){
cout << c;
}
return 0;
}
}
cout << -1;
return 0;
int lo = 0;
int hi = 1e9;
while(lo<hi){
int mid = (lo+hi)/2;
if(check(mid)){
hi=mid;
}
else{
lo=mid+1;
}
}
if(lo==1e9){
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... | ||||
