이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
///~~~LOTA~~~///
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define append push_back
#define add insert
#define nl "\n"
#define ff first
#define ss second
#define pii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL)
#define N 100001
ll h[N];
ll c[N];
ll dp[N];
void solve(){
ll n,m;
cin>>n;
for(int i=0;i<n;i++)
cin>>h[i];
cin>>m;
for(int i=1;i<n;i++){
dp[i]=1e18;
cin>>m;
for(int j=0;j<i;j++){
dp[i]=min(dp[i],dp[j]+(h[j]-h[i])*(h[j]-h[i]));
dp[j]+=m;
}
}
cout<<dp[n-1];
}
int main(){
L0TA;
solve();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |