Submission #468450

# Submission time Handle Problem Language Result Execution time Memory
468450 2021-08-28T10:58:30 Z idk321 Building Bridges (CEOI17_building) C++17
30 / 100
3000 ms 3652 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll INF = 1000000000000000006LL;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;
    vector<ll> h(n);
    for (int i = 0; i < n; i++) cin >> h[i];
    vector<ll> w(n);
    for (int i = 0; i < n; i++) cin >> w[i];
    vector<ll> dp(n, INF);
    dp[0] = 0;
    for (int i = 1; i < n; i++) {
        ll cost = 0;
        for (int j = i - 1; j >= 0; j--) {
            dp[i] = min(dp[i], dp[j] + cost + (h[i] - h[j]) *  (h[i] - h[j]));
            cost += w[j];
        }
    }

    cout << dp[n - 1] << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3073 ms 3652 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
6 Execution timed out 3073 ms 3652 KB Time limit exceeded
7 Halted 0 ms 0 KB -