Submission #106399

#TimeUsernameProblemLanguageResultExecution timeMemory
106399tictaccatMeetings (IOI18_meetings)C++14
0 / 100
5546 ms1528 KiB
#include "meetings.h"
#include <bits/stdc++.h>

using namespace std;

int Q,N;

std::vector<long long> minimum_costs(std::vector<int> H, std::vector<int> L, std::vector<int> R) {
  Q = L.size(); N = H.size();

  vector<long long> C(Q);

  for (int q = 0; q < Q; q++) {
    int minCost = -1;
    for (int x = L[q]; x <= R[q]; x++) {
      int cost = 0;
      int high = 0;
      for (int j = x; j >= L[q]; j--) {
        high = max(high,H[j]);
        cost += high;
      }
      high = H[x];
      for (int j = x+1; j <= R[q]; j++) {
        high = max(high,H[j]);
       // cout << high << "\n";
        cost += high;
      }
     // cout << x << " " << cost << "\n";
      minCost = (minCost == -1 ? cost : min(cost,minCost));
    }
    C[q] = minCost;
  }

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