# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
761158 |
2023-06-19T09:44:14 Z |
ksu2009en |
Peru (RMI20_peru) |
C++17 |
|
1 ms |
340 KB |
#include "peru.h"
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <bitset>
#include <cstring>
#include <unordered_map>
using namespace std;
typedef long long ll;
ll const mod = (ll)(1e9 + 7);
int solve(int n, int k, int* a){
vector<ll>dp(n);
dp[0] = a[0];
for(int i = 1; i < n; i++){
dp[i] = dp[i - 1] + a[i];
ll mx = 0;
for(int j = i; j >= max(0, i - k + 1); j--){
mx = max(mx, (ll)a[j]);
dp[i] = min(dp[i], mx + (j - 1 >= 0 ? dp[j - 1] : 0));
}
}
ll p = 1;
ll ans = 0;
for(int i = n - 1; i >= 0; i--){
ans = (ans + (p * dp[i]) % mod) % mod;
p = (p * 23) % mod;
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |