Submission #900529

# Submission time Handle Problem Language Result Execution time Memory
900529 2024-01-08T12:45:20 Z Cookie Peru (RMI20_peru) C++14
0 / 100
1 ms 4440 KB
#include<bits/stdc++.h>
#include<fstream>
using namespace std;
#define sz(a) (int)a.size()
#define ALL(v) v.begin(), v.end()
#define ALLR(v) v.rbegin(), v.rend()
#define ll long long
#define pb push_back
#define forr(i, a, b) for(int i = a; i < b; i++)
#define dorr(i, a, b) for(int i = a; i >= b; i--)
#define ld long double
#define vt vector
#include<fstream>
#define fi first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>
#define mpp make_pair
#include<iostream>
#include "peru.h"
using namespace std;
const int mxn = 4e5 + 5;
const ll mod = 1e9 + 7;
ll a[mxn + 1];
ll dp[mxn + 1], pw[mxn + 1];
int solve(int n, int k, int* v){
    pw[0] = 1;
    for(int i = 1; i < n; i++)pw[i] = (pw[i - 1] * 23) % mod;
    for(int i = 1; i <= n; i++)a[i] = v[i - 1];
    ll ans = 0;
    for(int i = 1; i <= n; i++){
        dp[i] = dp[i - 1] + a[i];
        ll mx = a[i];
        for(int j = i - 1; j >= max(i - k + 1, 1); j--){
            mx = max(mx, a[j]);
            dp[i] = min(dp[i], dp[j - 1] + mx);
        }
        ans = (ans + (dp[i] % mod) * pw[n - i]) % mod;
        //cout << dp[i] << " ";
    }
    cout << ans;
    return 0;
}
 
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4440 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4440 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4440 KB Output isn't correct
2 Halted 0 ms 0 KB -