제출 #424939

#제출 시각아이디문제언어결과실행 시간메모리
424939Pbezz모임들 (IOI18_meetings)C++14
19 / 100
640 ms383420 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...