Submission #1117569

#TimeUsernameProblemLanguageResultExecution timeMemory
1117569minggaBuilding Bridges (CEOI17_building)C++17
0 / 100
3038 ms4480 KiB
#include <bits/stdc++.h> using namespace std; #define ln '\n' #define fi first #define se second #define pb push_back #define all(x) (x).begin(), (x).end() #define sz(x) (int)(x).size() #define int long long const int inf = 2e18; const int N = 1e5 + 7; int h[N], w[N], n, ps[N], f[N]; signed main() { cin.tie(0) -> sync_with_stdio(0); cin >> n; for(int i = 1; i <= n; i++) cin >> h[i]; for(int i = 1; i <= n; i++) cin >> w[i], ps[i] = ps[i - 1] + w[i]; for(int i = 2; i <= n; i++) { f[i] = inf; for(int j = 0; j < i; j++) { f[i] = min(f[i], f[j] + ps[i - 1] - ps[j] + (h[i] - h[j]) * (h[i] - h[j])); } } cout << f[n]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...