제출 #142946

#제출 시각아이디문제언어결과실행 시간메모리
142946MilkiBuilding Bridges (CEOI17_building)C++14
30 / 100
3016 ms2868 KiB
#include<bits/stdc++.h> using namespace std; #define FOR(i, a, b) for(int i = a; i < b; ++i) #define REP(i, n) FOR(i, 0, n) #define _ << " " << #define sz(x) ((int) x.size()) #define pb(x) push_back(x) #define TRACE(x) cerr << #x << " = " << x << endl typedef long long ll; typedef pair<ll, ll> point; const int MAXN = 1e5 + 5, MAXV = 105; const ll inf = 1e16; int n, h[MAXN], w[MAXN]; ll dp[MAXN]; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cin >> n; REP(i, n) cin >> h[i + 1]; REP(i, n){ cin >> w[i + 1]; if(i > 0) w[i + 1] += w[i]; } FOR(i, 2, n + 1){ dp[i] = inf; FOR(j, 1, i) dp[i] = min(dp[i], dp[j] + (h[i] - h[j]) * (h[i] - h[j]) + w[i - 1] - w[j] ); } cout << dp[n]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...