#include <bits/stdc++.h>
using namespace std;
#include "meetings.h"
typedef long long LL;
vector<int> h;
int N,Q;
LL Dp[5010][5010];
int findmax(int l,int r){
int M=l;
for (int i=l;i<=r;i++)
if(h[i]>h[M])M=i;
return M;
}
LL dp(int l,int r){
if(l>r)return 0;
if (Dp[l][r]>0)return Dp[l][r];
if(l==r)return Dp[l][r]=h[l];
int x=findmax(l,r);
return Dp[l][r]=min(dp(l,x-1)+h[x]*(r-x+1),dp(x+1,r)+h[x]*(x-l+1));
}
vector<LL> minimum_costs(vector<int> H,vector<int> L,vector<int> R) {
N=H.size(),Q=L.size();
h=H;
vector<LL> C;
memset(Dp,0,sizeof(Dp));
for (int q=0;q<Q;q++){
C.push_back(dp(L[q],R[q]));
}
return C;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
163 ms |
196792 KB |
Output is correct |
2 |
Incorrect |
165 ms |
196804 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
163 ms |
196792 KB |
Output is correct |
2 |
Incorrect |
165 ms |
196804 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
163 ms |
196816 KB |
Output is correct |
2 |
Runtime error |
449 ms |
400024 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
163 ms |
196816 KB |
Output is correct |
2 |
Runtime error |
449 ms |
400024 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
163 ms |
196792 KB |
Output is correct |
2 |
Incorrect |
165 ms |
196804 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |