답안 #892671

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
892671 2023-12-25T16:38:28 Z tvladm2009 Building Bridges (CEOI17_building) C++17
30 / 100
3000 ms 3028 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

const ll INF = 1e18;

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> h(n + 1), w(n + 1);
    for (int i = 1; i <= n; i += 1) {
        cin >> h[i];
    }
    for (int i = 1; i <= n; i += 1) {
        cin >> w[i];
    }
    vector<ll> dp(n + 1, INF);
    dp[1] = 0;
    for (int i = 1; i <= n; i += 1) {
        ll sum = 0;
        for (int j = i + 1; j <= n; j += 1) {
            dp[j] = min(dp[j], dp[i] + (h[i] - h[j]) * (h[i] - h[j]) + sum);
            sum += w[j];
        }
    }
    cout << dp[n] << endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 452 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 2 ms 344 KB Output is correct
5 Correct 1 ms 464 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3091 ms 3028 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 452 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 2 ms 344 KB Output is correct
5 Correct 1 ms 464 KB Output is correct
6 Execution timed out 3091 ms 3028 KB Time limit exceeded
7 Halted 0 ms 0 KB -