# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1061006 | stdfloat | Cyberland (APIO23_cyberland) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "cyberland.h"
#include "stub.cpp"
using namespace std;
#define ld long double
double solve(int n, int M, int K, int H, vector<int> X, vector<int> Y, vector<int> C, vector<int> a) {
vector<vector<ld>> dp(H + 1, vector<ld>(K + 1, 1e18));
dp[0][0] = 0;
for (int i = 1; i <= H; i++) {
if (!a[i]) {
dp[i][0] = 0;
continue;
}
for (int j = 0; j <= K; j++) {
if (dp[i - 1][j] < 1e18) dp[i][j] = min(dp[i][j], dp[i - 1][j] + C[i - 1]);
if (j && a[i] == 2 && dp[i - 1][j - 1] < 1e18) dp[i][j] = min(dp[i][j], (dp[i - 1][j - 1] + C[i - 1]) / 2);
}
}
return *min_element(dp[H].begin(), dp[H].end());
}