# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
848912 |
2023-09-13T17:30:55 Z |
TahirAliyev |
Peru (RMI20_peru) |
C++17 |
|
1 ms |
344 KB |
#include "peru.h"
#include <bits/stdc++.h>
#define ll long long
#define oo 1e16
using namespace std;
const int MAX = 2002, MOD = 1e9 + 7;
int arr[MAX];
ll dp[MAX];
int solve(int n, int k, int* v){
for(int i = 1; i <= n; i++){
dp[i] = oo;
}
for(int i = 0; i < n; i++){
arr[i + 1] = v[i];
}
for(int i = 1; i <= n; i++){
int m = 0;
for(int j = 1; j <= k; j++){
if(i - j < 0) break;
m = max(arr[i - j + 1], m);
dp[i] = min(dp[i - j] + m, dp[i]);
}
}
ll ans = 0;
ll p = 1;
for(int i = n; i >= 1; i--){
ans += dp[i] * p % MOD;
ans %= MOD;
p *= 23;
p %= MOD;
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |