Submission #1037462

#TimeUsernameProblemLanguageResultExecution timeMemory
1037462omarpaladines95Meetings (IOI18_meetings)C++14
0 / 100
5593 ms1628 KiB
#include "meetings.h"

#include <bits/stdc++.h>

using namespace std;

long long minCostForCandidateIdx (const std::vector<int>& H, int L, int R, int candidateIdx)
{
  long long costForCandidate = 0;
  for (int i = L; i <= R; ++i)
  {
    int runMax = 0;
    if (i <= candidateIdx)
    {
      for (int k = i; k <= candidateIdx; ++k)
      {
        //cout << "( " << H[k] << " , " << minSize << ")"<< endl; 
        runMax = max(H[k], runMax);
      }
    }
    else
    {
      for (int k = candidateIdx; k <= i; ++k)
      { 
        //cout << "( " << H[k] << " , " << minSize << ")"<< endl; 
        runMax = max(H[k], runMax);
      }
    }
    //cout << "( " << candidateIdx << " , " << i << " , " << runMax << " ) " << endl; 
    costForCandidate += runMax;
  }
  //cout << "( " << candidateIdx << " , " << costForCandidate << " ) " << endl; 
  return costForCandidate;
}

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) {
    long long minSize = LLONG_MAX;
    for (int candidateIdx = L[j]; candidateIdx <= R[j]; ++candidateIdx)
    {
      long long curCost = minCostForCandidateIdx(H, L[j], R[j], candidateIdx);
      minSize = min(minSize, curCost);
    }
    C[j] = minSize;
  }
  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...