답안 #414499

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
414499 2021-05-30T13:54:52 Z ak2006 Building Bridges (CEOI17_building) C++14
30 / 100
3000 ms 2636 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vb = vector<bool>;
using vvb = vector<vb>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
const ll mod = 1e9 + 7,inf = 1e18;
#define pb push_back
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
void setIO()
{
    fast;
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("outut.txt","w",stdout);
    // #endif
}
int main()
{
    setIO();
    int n;
    cin>>n;
    vl h(n + 1),w(n + 1),dp(n + 1);
    ll sum = 0;
    for (int i = 1;i<=n;i++)cin>>h[i];
    for (int i = 1;i<=n;i++){cin>>w[i];sum += w[i];}
    dp[1] = -w[1];
    for (int i = 2;i<=n;i++){
        dp[i] = inf;
        for (int j = i - 1;j>=1;j--){
            dp[i] = min(dp[i],dp[j] + (h[i] - h[j]) * (h[i] - h[j]) - w[i]);//p[i - 1] - p[j]);
        }
    }
    cout<<dp[n] + sum;
    return 0;
}
# 결과 실행 시간 메모리 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 332 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3083 ms 2636 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 332 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
6 Execution timed out 3083 ms 2636 KB Time limit exceeded
7 Halted 0 ms 0 KB -