# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
876483 |
2023-11-21T20:08:26 Z |
MinaRagy06 |
Peru (RMI20_peru) |
C++17 |
|
2 ms |
4444 KB |
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#include "peru.h"
#ifdef MINA
#include "grader.cpp"
#endif
using namespace std;
#define ll long long
const int N = 2'500'005, mod = 1e9 + 7;
const ll inf = 1e18;
ll dp[N], a[N];
int solve(int n, int k, int *v) {
for (int i = 0; i < n; i++) {
a[i + 1] = v[i];
}
for (int i = 1; i <= n; i++) {
dp[i] = inf;
ll c = 0;
for (int j = i; j > max(0, i - k); j--) {
c = max(c, a[j]);
dp[i] = min(dp[i], dp[j - 1] + c);
}
}
int ans = 0;
ll pw = 1;
for (int i = n; i >= 1; i--) {
ans += pw * dp[i] % mod;
ans %= mod;
pw = pw * 23 % mod;
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4440 KB |
Output is correct |
2 |
Incorrect |
1 ms |
4444 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4440 KB |
Output is correct |
2 |
Incorrect |
1 ms |
4444 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4440 KB |
Output is correct |
2 |
Incorrect |
1 ms |
4444 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |