Submission #858860

# Submission time Handle Problem Language Result Execution time Memory
858860 2023-10-09T09:35:42 Z alexdumitru Peru (RMI20_peru) C++14
0 / 100
0 ms 344 KB
#include <bits/stdc++.h>

using namespace std;

const int MOD = 1e9 + 7;

int solve(int n, int k, int *s)
{
    int deq[n], dp[n];
    int l = 0, r = -1, mul = 1, ans = 0;
    for(int i = 0; i < n; i++)
    {
        while(r >= l && s[deq[r]] <= s[i]) r--;
        deq[++r] = i;
        if(deq[l] <= i - k) l++;
        int nextDp = i >= k ? dp[i - k] : 0;
        dp[i] = (nextDp + s[deq[l]]) % MOD;
    }
    for(int i = n - 1; i >= 0; i--)
    {
        ans = (1LL * ans + 1LL * dp[i] * mul % MOD) % MOD;
        mul = (1LL * mul * 23) % MOD;
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -