제출 #433468

#제출 시각아이디문제언어결과실행 시간메모리
433468JovanK26Building Bridges (CEOI17_building)C++14
30 / 100
3052 ms2772 KiB
#include <bits/stdc++.h> using namespace std; int h[100001]; int w[100001]; long long f[100001]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; for(int i=0;i<n;i++) { cin >> h[i]; f[i]=1000000000000000000; } long long tot=0; for(int i=0;i<n;i++) { cin >> w[i]; tot+=w[i]; } f[0]=-w[0]; for(int i=1;i<n;i++) { for(int j=0;j<i;j++) { f[i]=min(f[i],f[j]+(h[i]-h[j])*(h[i]-h[j])-w[i]); } } cout << tot+f[n-1]; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...