| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1364341 | Aviansh | Sprinklers (CEOI24_sprinklers) | C++20 | 2095 ms | 2060 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];
}
char ans[n];
auto check = [&] (int k){
for(int mask = 0;mask<(1<<n);mask++){
int cnt[m];
fill(cnt,cnt+m,0);
for(int i = 0;i<n;i++){
if(mask&(1<<i)){
//go right
int lo = s[i];
int ind = lower_bound(f,f+m,lo)-f;
while(ind<m&&f[ind]<=s[i]+k){
cnt[ind]++;
ind++;
}
}
else{
//go left
int lo = s[i]-k;
int ind = lower_bound(f,f+m,lo)-f;
while(ind<m&&f[ind]<=s[i]){
cnt[ind]++;
ind++;
}
}
}
if((*min_element(cnt,cnt+m))==0){
}
else{
for(int i = 0;i<n;i++){
if((1<<i)&(mask)){
//go right
ans[i]='R';
}
else{
//go left
ans[i]='L';
}
}
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... | ||||
