제출 #1026218

#제출 시각아이디문제언어결과실행 시간메모리
1026218Lalic모임들 (IOI18_meetings)C++17
19 / 100
1740 ms786432 KiB
#include "meetings.h"
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define mp make_pair

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef complex<double> cd;

const ll LINF = 0x3f3f3f3f3f3f3f3f;

vector<long long> minimum_costs(vector<int> H, vector<int> L, vector<int> R) {
	int q=(int)L.size(), n=(int)H.size();
	
	vector<ll> ans(q);
	vector<vector<ll>> res(n, vector<ll>(n));
	
	for(int i=0;i<n;i++){
		res[i][i]=H[i];
		int curr=H[i];
		for(int j=i+1;j<n;j++){
			curr=max(curr, H[j]);
			res[i][j]=res[i][j-1]+curr;
		}
		
		curr=H[i];
		for(int j=i-1;j>=0;j--){
			curr=max(curr, H[j]);
			res[i][j]=res[i][j+1]+curr;
		}
	}
	
	for(int i=0;i<q;i++){
		ll best=LINF;
		for(int j=L[i];j<=R[i];j++) best=min(best, res[j][L[i]]+res[j][R[i]]-H[j]);
		ans[i]=best;
	}
	
	return ans;
}
#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...