Submission #856312

# Submission time Handle Problem Language Result Execution time Memory
856312 2023-10-03T05:38:28 Z Cyanmond Building Bridges (CEOI17_building) C++17
30 / 100
3000 ms 3680 KB
#include <bits/stdc++.h>

using namespace std;

#define rep(i, l, r) for (int i = (l); i < (r); ++i)
#define per(i, l, r) for (int i = (r - 1); i >= l; --i)
#define ALL(x) (x).begin(), (x).end()

using i64 = long long;

void main_() {
    int N;
    cin >> N;
    vector<i64> H(N), W(N);
    for (auto &e : H) cin >> e;
    for (auto &e : W) cin >> e;

    vector<i64> dp(N, 1ll << 60);
    dp[0] = 0;
    rep(i, 0, N) {
        i64 sumW = 0;
        rep(j, i + 1, N) {
            dp[j] = min(dp[j], dp[i] + (H[i] - H[j]) * (H[i] - H[j]) + sumW);
            sumW += W[j];
        }
    }
    cout << dp[N - 1] << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    main_();
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 600 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3028 ms 3680 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 600 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Execution timed out 3028 ms 3680 KB Time limit exceeded
7 Halted 0 ms 0 KB -