#include <bits/stdc++.h>
#include <peru.h>
using namespace std;
#define Mod 1000000007
int solve ( int n, int k, int* v ){
long long int dp[n + 1];
dp[0] = 0;
for(int i = 1; i <= n; i++){
int maxi = v[i - 1];
dp[i] = INT_MAX;
//cout << "i = " << i << " maxi = " << maxi << endl;
for(int j = i - 1; j >= 0 && i - j <= k; j--){
dp[i] = min( dp[i], dp[j] + maxi );
//cout << " -- > j = " << j << " dp[j] = " << dp[j] << " maxi = " << maxi << endl;
maxi = max( v[j - 1], maxi );
}
}
/*
cout << "dp : ";
for(int i = 1; i <= n; i++) cout << dp[i] << " ";
cout << endl;
*/
long long int sum = 0;
long long int p = 1;
for(int i = n; i > 0; i--){
sum += (p * dp[i]) % Mod;
p *= 23;
p %= Mod;
}
return sum;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |