Submission #1221967

#TimeUsernameProblemLanguageResultExecution timeMemory
1221967madamadam3Meetings (IOI18_meetings)C++20
4 / 100
5594 ms1608 KiB
#include "meetings.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll INF = 1e18;

vector<ll> minimum_costs(vector<int> H, vector<int> L, vector<int> R) {
  int Q = L.size();
  vector<ll> C(Q);

  for (int j = 0; j < Q; ++j) {
    ll best = INF;
    for (int x = L[j]; x <= R[j]; x++) {
      ll cost = 0;

      int lmax = 0;
      for (int i = x - 1; i >= L[j]; i--) {
        lmax = max(lmax, H[i]);
        cost += lmax;
      }

      int rmax = 0;
      for (int i = x; i <= R[j]; i++) {
        rmax = max(rmax, H[i]);
        cost += rmax;
      }

      best = min(best, cost);
    }

    C[j] = best;
  }

  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...