Submission #399323

# Submission time Handle Problem Language Result Execution time Memory
399323 2021-05-05T15:01:30 Z rocks03 Peru (RMI20_peru) C++14
0 / 100
3 ms 340 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define pb push_back
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << ": " << x << " "
#define nl cout << "\n"
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define per(i, a, b) for(int i = (a); i >= (b); i--)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int M = 1e9 + 7;

int solve(int N, int K, int* a){
    vector<int> dp(N + 1, INT_MAX);
    dp[0] = 0;
    multiset<int> st;
    rep(i, 1, N + 1){
        st.insert(a[i - 1]);
        if(i > K){
            st.erase(st.find(a[i - K - 1]));
            rep(j, i - K + 1, i){
                dp[i] = min(dp[i], dp[j - 1] + *st.rbegin());
            }
        } else{
            dp[i] = *st.rbegin();
        }
    }
    vector<ll> pt(N + 1);
    pt[N] = 1;
    per(i, N - 1, 1){
        pt[i] = (pt[i + 1] * 23ll) % M;
    }
    ll ans = 0;
    rep(i, 1, N + 1){
        ans += (dp[i] * pt[i]) % M;
        ans %= M;
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -