#include "meetings.h"
#include <bits/stdc++.h>
using namespace std;
vector<long long> minimum_costs(vector<int> H, vector<int> L, vector<int> R) {
int N = H.size(), Q = L.size();
vector<long long> A(Q);
vector<vector<long long>> cost(N, vector<long long>(N, 0));
for(int i = 0; i < N; ++i){
for(int j = i - 1, c = H[i]; j >= 0; --j){
c = max(c, H[j]);
cost[i][j] = cost[i][j + 1] + c;
}
for(int j = i + 1, c = H[i]; j < N; ++j){
c = max(c, H[j]);
cost[i][j] = cost[i][j - 1] + c;
}
}
for(int i = 0; i < Q; ++i){
long long ans = 1e18;
for(int j = L[i]; j <= R[i]; ++j){
long long C = cost[j][L[i]] + H[j] + cost[j][R[i]];
ans = min(ans, C);
}
A[i] = ans;
}
return A;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
56 ms |
70996 KB |
Output is correct |
3 |
Correct |
57 ms |
70992 KB |
Output is correct |
4 |
Correct |
55 ms |
70996 KB |
Output is correct |
5 |
Correct |
58 ms |
71248 KB |
Output is correct |
6 |
Correct |
56 ms |
70988 KB |
Output is correct |
7 |
Correct |
56 ms |
71052 KB |
Output is correct |
8 |
Correct |
55 ms |
71048 KB |
Output is correct |
9 |
Correct |
58 ms |
70820 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
56 ms |
70996 KB |
Output is correct |
3 |
Correct |
57 ms |
70992 KB |
Output is correct |
4 |
Correct |
55 ms |
70996 KB |
Output is correct |
5 |
Correct |
58 ms |
71248 KB |
Output is correct |
6 |
Correct |
56 ms |
70988 KB |
Output is correct |
7 |
Correct |
56 ms |
71052 KB |
Output is correct |
8 |
Correct |
55 ms |
71048 KB |
Output is correct |
9 |
Correct |
58 ms |
70820 KB |
Output is correct |
10 |
Correct |
328 ms |
196600 KB |
Output is correct |
11 |
Correct |
387 ms |
196908 KB |
Output is correct |
12 |
Correct |
320 ms |
196508 KB |
Output is correct |
13 |
Correct |
385 ms |
196600 KB |
Output is correct |
14 |
Correct |
333 ms |
196432 KB |
Output is correct |
15 |
Correct |
359 ms |
196428 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
3372 ms |
505684 KB |
Output is correct |
3 |
Runtime error |
357 ms |
786432 KB |
Execution killed with signal 9 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
3372 ms |
505684 KB |
Output is correct |
3 |
Runtime error |
357 ms |
786432 KB |
Execution killed with signal 9 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
56 ms |
70996 KB |
Output is correct |
3 |
Correct |
57 ms |
70992 KB |
Output is correct |
4 |
Correct |
55 ms |
70996 KB |
Output is correct |
5 |
Correct |
58 ms |
71248 KB |
Output is correct |
6 |
Correct |
56 ms |
70988 KB |
Output is correct |
7 |
Correct |
56 ms |
71052 KB |
Output is correct |
8 |
Correct |
55 ms |
71048 KB |
Output is correct |
9 |
Correct |
58 ms |
70820 KB |
Output is correct |
10 |
Correct |
328 ms |
196600 KB |
Output is correct |
11 |
Correct |
387 ms |
196908 KB |
Output is correct |
12 |
Correct |
320 ms |
196508 KB |
Output is correct |
13 |
Correct |
385 ms |
196600 KB |
Output is correct |
14 |
Correct |
333 ms |
196432 KB |
Output is correct |
15 |
Correct |
359 ms |
196428 KB |
Output is correct |
16 |
Correct |
0 ms |
344 KB |
Output is correct |
17 |
Correct |
3372 ms |
505684 KB |
Output is correct |
18 |
Runtime error |
357 ms |
786432 KB |
Execution killed with signal 9 |
19 |
Halted |
0 ms |
0 KB |
- |