답안 #46977

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
46977 2018-04-25T16:10:28 Z dqhungdl Building Bridges (CEOI17_building) C++17
30 / 100
3000 ms 3852 KB
#include <bits/stdc++.h>
using namespace std;

int64_t n,a[100005],b[100005],f[100005];

int main()
{
    ios_base::sync_with_stdio(false);
    //freopen("TEST.INP","r",stdin);
    cin>>n;
    for(int64_t i=1;i<=n;i++)
        cin>>a[i];
    for(int64_t i=1;i<=n;i++)
    {
        cin>>b[i];
        b[i]+=b[i-1];
    }
    f[1]=0;
    for(int64_t i=2;i<=n;i++)
    {
        f[i]=1e18;
        for(int64_t j=1;j<i;j++)
            f[i]=min(f[i],f[j]+(a[i]-a[j])*(a[i]-a[j])+b[i-1]-b[j]);
    }
    cout<<f[n];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 436 KB Output is correct
4 Correct 3 ms 568 KB Output is correct
5 Correct 3 ms 672 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3049 ms 3852 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 436 KB Output is correct
4 Correct 3 ms 568 KB Output is correct
5 Correct 3 ms 672 KB Output is correct
6 Execution timed out 3049 ms 3852 KB Time limit exceeded
7 Halted 0 ms 0 KB -