Submission #468450

#TimeUsernameProblemLanguageResultExecution timeMemory
468450idk321Building Bridges (CEOI17_building)C++17
30 / 100
3073 ms3652 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll INF = 1000000000000000006LL; int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<ll> h(n); for (int i = 0; i < n; i++) cin >> h[i]; vector<ll> w(n); for (int i = 0; i < n; i++) cin >> w[i]; vector<ll> dp(n, INF); dp[0] = 0; for (int i = 1; i < n; i++) { ll cost = 0; for (int j = i - 1; j >= 0; j--) { dp[i] = min(dp[i], dp[j] + cost + (h[i] - h[j]) * (h[i] - h[j])); cost += w[j]; } } cout << dp[n - 1] << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...