제출 #601583

#제출 시각아이디문제언어결과실행 시간메모리
601583Belgutei모임들 (IOI18_meetings)C++17
4 / 100
5548 ms1812 KiB
#include "meetings.h"
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mk make_pair

int l,r;
stack<pair<int,int> > pre,after;
vector<ll> ret;

std::vector<long long> minimum_costs(std::vector<int> H, std::vector<int> L,std::vector<int> R) {
  int q = L.size();
  for(int i = 0; i < q; i ++) {
    l = L[i];
    r = R[i];
    ll ans = 1e18;
    for(int j = l; j <= r; j ++) { // starting point
      ll tmp = H[j];
      ll mx = (ll) H[j];
      for(int x = j - 1; x >= l ; x --) {
        mx = max(mx, (ll) H[x]);
        tmp += mx;
      }
      mx = H[j];
      for(int x = j + 1; x <= r; x ++) {
        mx = max(mx, (ll) H[x]);
        tmp += mx;
      }
      ans = min(ans,tmp);
    } 
    ret.pb(ans);
    // while(pre.size() > 0) pre.pop();
    // while(after.size() > 0) after.pop();
    // ll cur = 0;
    // for(int j = l; j <= r; j ++) {
    //   if(after.size() == 0) after.push({H[j],j}); // value / position
    //   else if(after.top().ff <= H[j]) after.push({H[j],j});
    //   cur += after.top().ff;
    // }
    // ll ans = cur;

    // ret.pb(ans);
  }
  return ret;
}
#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...