# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1005914 | irmuun | Meetings (IOI18_meetings) | C++17 | 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<bits/stdc++.h>
#include "meeting.h"
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
vector<ll>minimum_costs(vector<int>H,vector<int>L,vector<int>R){
int n=H.size(),m=L.size();
vector<ll>ans(m,1e18);
ll l[n][n],r[n][n];
for(int i=0;i<n;i++){
int cur=0;
ll total=0;
for(int j=i;j<n;j++){
cur=max(cur,H[j]);
total+=cur;
l[i][j]=total;
}
}
for(int i=n-1;i>=0;i--){
int cur=0;
ll total=0;
for(int j=i;j>=0;j--){
cur=max(cur,H[j]);
total+=cur;
r[j][i]=total;
}
}
for(int j=0;j<m;j++){
for(int x=L[j];x<=R[j];x++){
ans[j]=min(ans[j],r[L[j]][x]+l[x][R[j]]-H[x]);
}
}
return ans;
}