This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define Tupizm ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define ONE exit(0);
#define nl "\n"
#define fly return
#define all(x) x.begin(0), x.end(0);
#define sz(x) (int)x.size();
#define pb push_back
#define ppb pop_back
typedef long long ll;
typedef double db;
const int N = 1e5 + 5;
const int M = 1e9 + 7;
int n, a[N], b[N];
int dp[N];
int sum(int l, int r){
int q = 0;
for(int i = l + 1; i < r; ++i){
q += b[i];
}
fly q;
}
int hello(){
for(int i = 2; i <= n; ++i){
dp[i] = M;
}
}
int pff(int l, int r){
return (a[l] - a[r]) * (a[l] - a[r]);
}
int main(){
Tupizm
cin >> n;
hello();
for(int i = 1; i <= n; ++i){
cin >> a[i];
}
for(int i = 1; i <= n; ++i){
cin >> b[i];
}
for(int i = 2; i <= n; ++i){
for(int j = i - 1; j >= 1; --j){
dp[i] = min(dp[i], dp[j] + sum(j, i) + (pff(i, j)));
}
}
cout << dp[n] << nl;
ONE
}
Compilation message (stderr)
building.cpp: In function 'int hello()':
building.cpp:37:1: warning: no return statement in function returning non-void [-Wreturn-type]
}
^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |