# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
624719 | moyindavid | Meetings (IOI18_meetings) | C++17 | 808 ms | 786432 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>
using namespace std;
vector<long long> minimum_costs(vector<int> H, vector<int> L,vector<int> R) {
int n=H.size(),cost[n][n];
for(int i=0;i<n;i++){
cost[i][i]=H[i];
for(int j=i+1;j<n;j++)cost[i][j]=max(cost[i][j-1],H[j]);
}
for(int i=n-1;i>=0;i--){
for(int j=i-1;j>=0;j--)cost[i][j]=max(cost[i][j+1],H[j]);
}
int Q = L.size();
vector<long long> C(Q,3000000000007);
long long left[n][n],right[n][n],temp=0;
for(int i=0;i<n;i++)for(int j=0;j<n;j++){left[i][j]=0;right[i][j]=0;}
for(int i=0;i<n;i++){
left[i][i]=cost[i][i];
for(int k=i-1;k>=0;k--){
left[k][i]=cost[k][i]+left[k+1][i];
}
right[i][i]=cost[i][i];
for(int k=i+1;k<n;k++){
right[k][i]=cost[k][i]+right[k-1][i];
}
}
for (int j = 0; j < Q; ++j) {
for(int i=L[j];i<=R[j];i++){
if(i==L[j])C[j]=min(C[j],right[R[j]][i]);
else if(i==R[j])C[j]=min(C[j],left[L[j]][i]);
else C[j]=min(C[j],-cost[i][i]+right[R[j]][i]+left[L[j]][i]);
}
}
return C;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |