Submission #934235

# Submission time Handle Problem Language Result Execution time Memory
934235 2024-02-27T03:11:57 Z Sir_Ahmed_Imran Building Bridges (CEOI17_building) C++17
30 / 100
3000 ms 3232 KB
                              ///~~~LOTA~~~///
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define append push_back
#define add insert
#define nl "\n"
#define ff first
#define ss second
#define pii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL)
#define N 100001
ll h[N];
ll c[N];
ll dp[N];
void solve(){
    ll n,m;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>h[i];
    cin>>m;
    for(int i=1;i<n;i++){
        dp[i]=1e18;
        cin>>m;
        for(int j=0;j<i;j++){
            dp[i]=min(dp[i],dp[j]+(h[j]-h[i])*(h[j]-h[i]));
            dp[j]+=m;
        }
    }
    cout<<dp[n-1];
}
int main(){
    L0TA;
    solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3003 ms 3232 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Execution timed out 3003 ms 3232 KB Time limit exceeded
7 Halted 0 ms 0 KB -