# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1106398 |
2024-10-30T09:08:14 Z |
LucaLucaM |
Peru (RMI20_peru) |
C++17 |
|
600 ms |
14700 KB |
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#warning That's not the baby, that's my baby
#define debug(x) #x << " = " << x << '\n'
using ll = long long;
const ll INF = 1e18;
const int mod = 1e9 + 7;
int toHash(std::vector<ll> x) {
int ret = 0;
for (int i = 0; i < (int) x.size(); i++) {
x[i] %= mod;
ret = ((ll) ret * 23 + x[i]) % mod;
}
return ret;
}
int solve(int n, int k, int *A) {
std::vector<ll> dp(n + 1, INF);
std::vector<int> a(n + 1, 0);
for (int i = 0; i < n; i++) {
a[i + 1] = A[i];
}
dp[0] = 0;
for (int i = 1; i <= n; i++) {
int maxi = 0;
for (int j = i; j > 0 && j > i - k; j--) {
maxi = std::max(maxi, a[j]);
dp[i] = std::min(dp[i], dp[j - 1] + maxi);
}
}
dp.erase(dp.begin());
return toHash(dp);
}
#ifdef LOCAL
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(0);
std::cout.tie(0);
#ifdef LOCAL
freopen("input.txt", "r", stdin);
#endif
int n, k;
std::cin >> n >> k;
int *a = new int[n];
for (int i = 0; i < n; i++) {
std::cin >> a[i];
}
std::cout << solve(n, k, a);
return 0;
}
#endif
Compilation message
peru.cpp:5:2: warning: #warning That's not the baby, that's my baby [-Wcpp]
5 | #warning That's not the baby, that's my baby
| ^~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
472 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
504 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
472 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
504 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
418 ms |
14664 KB |
Output is correct |
16 |
Correct |
338 ms |
14660 KB |
Output is correct |
17 |
Correct |
196 ms |
14672 KB |
Output is correct |
18 |
Correct |
215 ms |
14700 KB |
Output is correct |
19 |
Correct |
269 ms |
14672 KB |
Output is correct |
20 |
Correct |
551 ms |
14664 KB |
Output is correct |
21 |
Correct |
367 ms |
14648 KB |
Output is correct |
22 |
Execution timed out |
760 ms |
14656 KB |
Time limit exceeded |
23 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
418 ms |
14664 KB |
Output is correct |
2 |
Correct |
338 ms |
14660 KB |
Output is correct |
3 |
Correct |
196 ms |
14672 KB |
Output is correct |
4 |
Correct |
215 ms |
14700 KB |
Output is correct |
5 |
Correct |
269 ms |
14672 KB |
Output is correct |
6 |
Correct |
551 ms |
14664 KB |
Output is correct |
7 |
Correct |
367 ms |
14648 KB |
Output is correct |
8 |
Execution timed out |
760 ms |
14656 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |