Submission #494804

# Submission time Handle Problem Language Result Execution time Memory
494804 2021-12-16T14:13:00 Z blue Discharging (NOI20_discharging) C++17
0 / 100
1000 ms 15944 KB
#include <iostream>
#include <vector>
#include <cassert>
using namespace std;

using ll = long long;
using vll = vector<ll>;

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

    int N;
    cin >> N;

    vll t(1+N);
    t[0] = 0;
    for(int i = 1; i <= N; i++) cin >> t[i];

    vll dp(1+N, 1'000'000'000'000'000'000LL);
    dp[0] = 0;

    vll diff;

    for(int i = 1; i <= N; i++)
    {
        ll curr_max = 0;
        for(int j = i-1; j >= 0; j--)
        {
            curr_max = max(curr_max, t[j+1]);
            dp[i] = min(dp[i], dp[j] + curr_max * (N - j));
        }

        // if(i > 1) diff.push_back(dp[i] - dp[i-1]);
        if(i > 2) assert(dp[i-1] - dp[i-2] >= dp[i] - dp[i-1]);
    }

    cout << dp[N] << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Runtime error 1 ms 448 KB Execution killed with signal 6
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1091 ms 15944 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Runtime error 1 ms 448 KB Execution killed with signal 6
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Runtime error 1 ms 448 KB Execution killed with signal 6
6 Halted 0 ms 0 KB -