제출 #1045176

#제출 시각아이디문제언어결과실행 시간메모리
1045176wood모임들 (IOI18_meetings)C++17
0 / 100
1 ms348 KiB
#include "meetings.h"
#include <bits/stdc++.h>
using namespace std;
std::vector<long long> minimum_costs(std::vector<int> H, std::vector<int> L,
                                     std::vector<int> R) {
  int Q = L.size();
  std::vector<long long> C(Q);
  for (int j = 0; j < Q; ++j) {
	  map<int,int> backwards;
	  long long res = LLONG_MAX;
	  for(int i = R[j]; i>=L[j]; i--)backwards[H[i]]++;
	  int mx = 0;
	  for(int i = L[j]; i<=R[j]; i++){
		  mx = max(mx,H[i]);
		  backwards[H[i]]--; 
		  if(backwards[H[i]] == 0) backwards.erase(H[i]);
		  res = min(res,(long long)(i-L[j]+1)*mx+(R[j]-i)*backwards.rbegin()->first);
	  }
	  C[j] = res;
  }
  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...