Submission #433468

# Submission time Handle Problem Language Result Execution time Memory
433468 2021-06-19T20:57:15 Z JovanK26 Building Bridges (CEOI17_building) C++14
30 / 100
3000 ms 2772 KB
#include <bits/stdc++.h>

using namespace std;
int h[100001];
int w[100001];
long long f[100001];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    for(int i=0;i<n;i++)
    {
        cin >> h[i];
        f[i]=1000000000000000000;
    }
    long long tot=0;
    for(int i=0;i<n;i++)
    {
        cin >> w[i];
        tot+=w[i];
    }
    f[0]=-w[0];
    for(int i=1;i<n;i++)
    {
        for(int j=0;j<i;j++)
        {
            f[i]=min(f[i],f[j]+(h[i]-h[j])*(h[i]-h[j])-w[i]);
        }
    }
    cout << tot+f[n-1];
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 2 ms 336 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3052 ms 2772 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 2 ms 336 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
6 Execution timed out 3052 ms 2772 KB Time limit exceeded
7 Halted 0 ms 0 KB -