Submission #640072

# Submission time Handle Problem Language Result Execution time Memory
640072 2022-09-13T13:46:49 Z danikoynov Peru (RMI20_peru) C++14
0 / 100
1 ms 328 KB
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const int maxn = 2010;
const ll inf = 1e18, mod = 1e9 + 7;

ll a[maxn], dp[maxn];
int solve(int n, int k, int *S)
{
    for (int i = 0; i < n; i ++)
        a[i + 1] = S[i];

    for (int i = 1; i <= n; i ++)
    {
        dp[i] = inf;
        ll mx = a[i];
        for (int j = i - 1; j >= max(0, i - k); j --)
        {
            dp[i] = min(dp[i], dp[j] + mx);
            mx = max(mx, a[j]);
        }
    }

    for (int i = 1; i <= n; i ++)
        cout << dp[i] << " ";
    cout << endl;
    ll cur = 1, ans = 0;
    for (int i = n; i > 0; i --)
    {
        ans = (ans + (dp[i] % mod) * cur) % mod;
        cur = (cur * (ll)23) % mod;
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 328 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 328 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 328 KB Output isn't correct
2 Halted 0 ms 0 KB -