답안 #987717

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
987717 2024-05-23T12:13:47 Z ErJ Building Bridges (CEOI17_building) C++17
30 / 100
3000 ms 3672 KB
#include<bits/stdc++.h>

#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define pp pair<ll, ll>
#define inf 1000000000000000
#define rep(i,n) for(int i = 0; i < n; i++)

using namespace std;

int main(){
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    ll Wsum = 0;
    vi h(n);
    rep(i,n){
        cin >> h[i];
    }
    vi w(n);
    rep(i,n){
        cin >> w[i];
        Wsum += w[i];
    }
    vi dp(n, inf);
    dp[0] = -w[0];
    for(int i = 1; i < n; i++){
        for(int j = 0; j < i; j++){
            dp[i] = min(dp[i], dp[j] + (h[i] - h[j])*(h[i] - h[j]) - w[i]);
        }
    }
    cout << dp[n-1] + Wsum << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 2 ms 500 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3017 ms 3672 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 2 ms 500 KB Output is correct
6 Execution timed out 3017 ms 3672 KB Time limit exceeded
7 Halted 0 ms 0 KB -