이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "meetings.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
typedef pair<ll,ll> pii;
const ll MAXN = 5005;
const ll INF = 1e16+7;
ll cost[MAXN][MAXN];
std::vector<long long> minimum_costs(std::vector<int>H,std::vector<int>L,
std::vector<int> R) {
int Q = L.size(),n=H.size(),i,j,maxi;
ll k;
std::vector<long long> C(Q);
for(i=0;i<n;i++){
cost[i][i]=0; maxi=H[i];
for(j=i+1;j<n;j++){
maxi=max(maxi,H[j]);
cost[i][j]=cost[i][j-1]+maxi;
}
}
for(i=1;i<n;i++){maxi=H[i];
for(j=i-1;j>=0;j--){
maxi=max(maxi,H[j]);
cost[i][j]=cost[i][j+1]+maxi;
}
}
ll ans=INF;
for(i=0;i<Q;i++){ans=INF;
for(j=L[i];j<=R[i];j++){
k = cost[j][L[i]] + cost[j][R[i]] + H[j];
ans=min(ans,k);
}
C[i]=ans;
}
return C;
}
| # | 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... |