#include "cyberland.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using ld = long double;
double solve(int N, int M, int K, int H, std::vector<int> x, std::vector<int> y, std::vector<int> c, std::vector<int> arr) {
// literally a line
ll start = 0;
for(int i = H-1; i >= 0; i--){
if(arr[i] == 0){
start = i;
break;
}
}
ll gasStation = 0;
for(int i = H; i >= start; i--){
// get the first 2
if(arr[i] == 2){
gasStation = i;
break;
}
}
// if gas station is 0 then its just dist(start,end)
if(gasStation == 0 || K == 0){
ll ans = 0;
for(int i = start; i < H; i++){
ans += c[i];
}
return ans;
}
// otherwise
ld price = min(c[gasStation], c[gasStation - 1]) * 2;
ld ans = 0;
for(int i = start; i < gasStation; i++){
ans += c[i];
}
ans /= ld(2);
// we are now at the gas station
K--;
for(int i = 1; i <= K; i++){
ans += price;
ans /= ld(2);
}
for(int i = gasStation; i < H; i++){
ans += c[i];
}
return ans;
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |