Submission #790681

#TimeUsernameProblemLanguageResultExecution timeMemory
790681petezaMeetings (IOI18_meetings)C++14
4 / 100
5554 ms201600 KiB
#include "meetings.h"
#include <iostream>

int dp[5005][5005];
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);
  //std::cout << "HELLO";
  for(int i=0;i<H.size();i++) {
    int cm = H[i];
    for(int j=i;j>=0;j--) {
      cm = std::max(cm, H[j]);
      dp[i][j] = cm;
    }
    cm = H[i];
    for(int j=i;j<H.size();j++) {
      cm = std::max(cm, H[j]);
      dp[i][j] = cm;
    }
  }
  for (int j = 0; j < Q; ++j) {
    long long curans = __LONG_LONG_MAX__;
    for(int k=L[j];k<=R[j];k++) {
      long long csum = 0;
      for(int i=L[j];i<=R[j];i++)
        csum += dp[i][k];
      curans = std::min(curans, csum);
    }
    C[j] = curans;
  }
  return C;
}

/*
4 2
2 4 3 5
0 2
1 3
*/

Compilation message (stderr)

meetings.cpp: In function 'std::vector<long long int> minimum_costs(std::vector<int>, std::vector<int>, std::vector<int>)':
meetings.cpp:10:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |   for(int i=0;i<H.size();i++) {
      |               ~^~~~~~~~~
meetings.cpp:17:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for(int j=i;j<H.size();j++) {
      |                 ~^~~~~~~~~
#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...