# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
601725 | enerelt14 | Meetings (IOI18_meetings) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "meetings.h"
#include<bits/stdc++.h>
#define pb push_back
#define int long long
using namespace std;
int cost[5005][5005];
vector<long long> minimum_costs(vector<int> H, vector<int> L, vector<int> R){
for (int i=0;i<H.size();i++){
cost[i][i]=H[i];
for(int j=i+1;j<H.size();j++){
cost[i][j]=max(cost[i][j-1], H[j]);
}
}
for (int i=0;i<H.size();i++){
for (int j=0;j<i;j++){
cost[i][j]=cost[j][i];
}
}
for (int i=0;i<H.size();i++){
for (int j=0;j<H.size();j++){
cost[i][j]+=cost[i][j-1];
}
}
vector<long long>res;
for (int i=0;i<L.size();i++){
long long ans=1e15;
for (int j=L[i];j<=R[i];j++){
if (L[i]!=0)ans=min(ans, cost[j][R[i]]-cost[j][L[i]-1]);
else ans=min(ans, cost[j][R[i]]);
}
res.pb(ans);
}
return res;
}