제출 #689748

#제출 시각아이디문제언어결과실행 시간메모리
689748zeroesandonesDischarging (NOI20_discharging)C++17
36 / 100
1094 ms20980 KiB
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll, ll> pi;

#define FOR(i, j, k) for (ll i = j; i < (ll) k; ++i)
#define FORD(i, j, k) for (ll i = j; i >= (ll) k; --i)
#define nl "\n"
#define sp " "

#define all(x) (x).begin(), (x).end()
#define sc second
#define fr first
#define pb emplace_back

const ll inf = 1e15;

void solve()
{
    ll n;
    cin >> n;

    ll t[n + 1];
    FOR(i, 1, n + 1)
        cin >> t[i];

    ll dp[n + 1] = {};
    FOR(i, 1, n + 1) {
        dp[i] = inf;
        ll mx = 0;
        FORD(j, i, 1) {
            mx = max(mx, t[j]);
            dp[i] = min(dp[i], dp[j - 1] + (n - j + 1) * mx);
        }
    }

    cout << dp[n] << nl;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...