# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
876866 |
2023-11-22T12:47:40 Z |
TAhmed33 |
Peru (RMI20_peru) |
C++14 |
|
30 ms |
29520 KB |
#include <bits/stdc++.h>
#include <peru.h>
using namespace std;
typedef long long ll;
const int MAXN = 2500000;
const int MOD = 1e9 + 7;
int add (int a, int b) {
a += b; if (a >= MOD) a -= MOD;
return a;
}
int sub (int a, int b) {
a -= b; if (a < 0) a += MOD;
return a;
}
int mul (int a, int b) {
return (a * 1ll * b) % MOD;
}
int pw[MAXN + 25];
ll dp[MAXN + 25];
int solve (int n, int k, int *s) {
pw[0] = 1; for (int i = 1; i < MAXN + 25; i++) {
pw[i] = mul(i, pw[i - 1]);
}
int ret = 0;
for (int i = 1; i <= n; i++) {
int mx = s[i - 1];
dp[i] = 1e18;
for (int j = i - 1; j >= i - k; j++) {
dp[i] = min(dp[i], dp[j] + mx);
mx = max(mx, s[i - 1]);
}
ret = add(ret, mul(pw[n - i], dp[i]));
}
return ret;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
30 ms |
29520 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
30 ms |
29520 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
30 ms |
29520 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |