#include "meetings.h"
#include <bits/stdc++.h>
using namespace std;
vector<long long> minimum_costs(vector<int> H, vector<int> L,vector<int> R) {
long long q = L.size();
long long n = H.size();
vector<long long > ans(q);
vector<vector<long long >> mn(n,vector<long long>(n,1e18));
for(long long i = 0; i < n; i++){
mn[i][i] = H[i];
long long curr = H[i];
for(long long j = i-1; j >= 0; j--){
curr = max(curr,H[j]*1ll);
mn[j][i] = curr;
}curr = H[i];
for(long long j = i+1; j < n; j++){
curr = max(curr,H[j]*1ll);
mn[j][i] = curr;
}
}
for(long long i = 0; i < n; i++){
for(long long j = 1; j < n; j++){
mn[j][i] += mn[j-1][i];
}
}
for(long long v = 0; v < q; v++){
long long l = L[v];
long long r = R[v];
long long cnt = 1e18;
for(long long i = l; i <= r; i++){
if(l == 0)cnt = min(cnt,mn[r][i]);
else cnt = min(cnt,mn[r][i]-mn[l-1][i]);
}
ans[v] = cnt;
}
return ans;
}
// int main(){
// }
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
139 ms |
70840 KB |
Output is correct |
3 |
Correct |
155 ms |
70792 KB |
Output is correct |
4 |
Correct |
165 ms |
70892 KB |
Output is correct |
5 |
Correct |
142 ms |
70888 KB |
Output is correct |
6 |
Correct |
144 ms |
70820 KB |
Output is correct |
7 |
Correct |
155 ms |
70904 KB |
Output is correct |
8 |
Correct |
145 ms |
70884 KB |
Output is correct |
9 |
Correct |
143 ms |
70888 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
139 ms |
70840 KB |
Output is correct |
3 |
Correct |
155 ms |
70792 KB |
Output is correct |
4 |
Correct |
165 ms |
70892 KB |
Output is correct |
5 |
Correct |
142 ms |
70888 KB |
Output is correct |
6 |
Correct |
144 ms |
70820 KB |
Output is correct |
7 |
Correct |
155 ms |
70904 KB |
Output is correct |
8 |
Correct |
145 ms |
70884 KB |
Output is correct |
9 |
Correct |
143 ms |
70888 KB |
Output is correct |
10 |
Correct |
538 ms |
196360 KB |
Output is correct |
11 |
Correct |
550 ms |
196320 KB |
Output is correct |
12 |
Correct |
536 ms |
196372 KB |
Output is correct |
13 |
Correct |
555 ms |
196364 KB |
Output is correct |
14 |
Correct |
540 ms |
196364 KB |
Output is correct |
15 |
Correct |
544 ms |
196340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1877 ms |
504728 KB |
Output is correct |
3 |
Runtime error |
249 ms |
786432 KB |
Execution killed with signal 9 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1877 ms |
504728 KB |
Output is correct |
3 |
Runtime error |
249 ms |
786432 KB |
Execution killed with signal 9 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
139 ms |
70840 KB |
Output is correct |
3 |
Correct |
155 ms |
70792 KB |
Output is correct |
4 |
Correct |
165 ms |
70892 KB |
Output is correct |
5 |
Correct |
142 ms |
70888 KB |
Output is correct |
6 |
Correct |
144 ms |
70820 KB |
Output is correct |
7 |
Correct |
155 ms |
70904 KB |
Output is correct |
8 |
Correct |
145 ms |
70884 KB |
Output is correct |
9 |
Correct |
143 ms |
70888 KB |
Output is correct |
10 |
Correct |
538 ms |
196360 KB |
Output is correct |
11 |
Correct |
550 ms |
196320 KB |
Output is correct |
12 |
Correct |
536 ms |
196372 KB |
Output is correct |
13 |
Correct |
555 ms |
196364 KB |
Output is correct |
14 |
Correct |
540 ms |
196364 KB |
Output is correct |
15 |
Correct |
544 ms |
196340 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
1877 ms |
504728 KB |
Output is correct |
18 |
Runtime error |
249 ms |
786432 KB |
Execution killed with signal 9 |
19 |
Halted |
0 ms |
0 KB |
- |