diff options
author | Anthony Wang | 2022-03-15 20:38:51 -0500 |
---|---|---|
committer | Anthony Wang | 2022-03-15 20:38:51 -0500 |
commit | 896c6ceeff605c935a5538e3d9eca40ea3c79c56 (patch) | |
tree | 69d97b50f5ced801f6043cbef0219a941239f892 /7.5 | |
parent | 4c488e4c73f2d0e2b96bf0c444c05d42e566dd11 (diff) |
Restructure directories AGAIN so contests from the same season are in the same directory
Diffstat (limited to '7.5')
-rw-r--r-- | 7.5/nov/gold/telewire.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/7.5/nov/gold/telewire.cpp b/7.5/nov/gold/telewire.cpp new file mode 100644 index 0000000..e68ae69 --- /dev/null +++ b/7.5/nov/gold/telewire.cpp @@ -0,0 +1,15 @@ +#include <algorithm> +#include <iostream> +using namespace std; +constexpr auto INF = (int)1e9; + +int main() { + int N, C, H, A[105], B[105], DP[105]; + cin >> N >> C; + for (int i = 0; i < N; i++) { cin >> H; + for (int j = 0; j <= 100; j++) DP[j] = (j < H ? INF : (j - H) * (j - H) + (i > 0) * min(A[j] + C * j, B[j] - C * j)); + for (int j = 0; j <= 100; j++) A[j] = min(DP[j] - C * j, (j <= 0 ? INF : A[j - 1])); + for (int j = 100; j >= 0; j--) B[j] = min(DP[j] + C * j, (j >= 100 ? INF : B[j + 1])); + } + cout << *min_element(DP, DP + 100) << endl; +} |