답안 #939080

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
939080 2024-03-06T05:25:52 Z vjudge1 Building Bridges (CEOI17_building) C++17
30 / 100
3000 ms 4172 KB
#include <bits/stdc++.h>
#define int long long
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
signed main(){
    ios_base::sync_with_stdio();
    cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    vector <int> h(n+1),w(n+1),pr(n+1),dp(n+1,1e18);
    for(int i=1;i<=n;i++)cin>>h[i];
    for(int i=1;i<=n;i++)cin>>w[i];
    for(int i=1;i<=n;i++)pr[i]=pr[i-1]+w[i];
    dp[1]=0;
    for(int i=2;i<=n;i++){
        for(int j=1;j<=i-1;j++){
            dp[i]=min(dp[i],dp[j]+(h[i]-h[j])*(h[i]-h[j])+pr[i-1]-pr[j]);
        }
    }
    cout<<dp[n]<<"\n";
}
/*
6
3  8 7 1 6 6
0 -1 9 1 2 0
*/
           
 
           
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 432 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3031 ms 4172 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 432 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Execution timed out 3031 ms 4172 KB Time limit exceeded
7 Halted 0 ms 0 KB -