Submission #858860

#TimeUsernameProblemLanguageResultExecution timeMemory
858860alexdumitruPeru (RMI20_peru)C++14
0 / 100
0 ms344 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...