제출 #1117570

#제출 시각아이디문제언어결과실행 시간메모리
1117570minggaBuilding Bridges (CEOI17_building)C++17
30 / 100
3074 ms3408 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 = 1; 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...