# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1152083 | SmuggingSpun | Building Bridges (CEOI17_building) | C++20 | 1 ms | 328 KiB |
#include<bits/stdc++.h>
#define taskname "A"
using namespace std;
typedef long long ll;
const ll INF = 1e18;
template<class T>void minimize(T& a, T b){
if(a > b){
a = b;
}
}
ll square(int x){
return 1LL * x * x;
}
int n;
namespace sub1{
void solve(){
vector<int>h(n + 1), w(n + 1);
for(int i = 1; i <= n; i++){
cin >> h[i];
}
for(int i = 1; i <= n; i++){
cin >> w[i];
}
vector<ll>dp(n + 1, INF);
dp[1] = 0;
for(int i = 2; i <= n; i++){
ll sum = 0;
for(int j = i - 1; j > 0; sum += w[j--]){
minimize(dp[i], dp[j] + square(h[i] - h[j]) + sum);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |