Submission #476200

# Submission time Handle Problem Language Result Execution time Memory
476200 2021-09-25T10:17:33 Z kakayoshi Building Bridges (CEOI17_building) C++14
0 / 100
2 ms 332 KB
#include <bits/stdc++.h>
using namespace std;
#define forw(i,a,b) for(ll i=a;i<=b;i++)
#define forb(i,a,b) for(ll i=a;i>=b;i--)
typedef long long int ll;
ll res,n,h[100005],w[100005],max1[100005],pre[100005],dp[100005];
void sub1()
{
    for (int i=2;i<=n;i++)
    {
        max1[i]=1e18;
        res=0;
        for (int j=i-1;j>=1;j--)
            {
                ll p=(h[i]-h[j])*(h[i]-h[j])+res+max1[j];
                if (p<max1[i]) max1[i]=p;
                res+=w[j];
            }
    }
    cout<<max1[n];
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    freopen("test.INP","r",stdin);
    freopen("test.OUT","w",stdout);
    cin>>n;
    for (int i=1;i<=n;i++)
        cin>>h[i];
    for (int i=1;i<=n;i++)
        cin>>w[i];
    sub1();
    //else sub2();
    //sub2();
    return 0;
}

Compilation message

building.cpp: In function 'int main()':
building.cpp:26:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |     freopen("test.INP","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
building.cpp:27:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |     freopen("test.OUT","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -