This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "meetings.h"
using ll = long long;
#define fore(a, b, c) for(int a=b; a<c; ++a)
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using namespace std;
int T[6050], n;
void update(int idx, int x){
    T[idx += n] = x;
    for(idx /= 2; idx; idx /= 2){
        T[idx] = max(T[2*idx], T[2*idx+1]);
    }
}
int query(int low, int high){
    int ra = 0, rb = 0;
    for(low += n, high += n + 1; low < high; low /= 2, high /= 2){
        if(low & 1) ra = max(ra, T[low++]);
        if(high & 1) rb = max(rb, T[--high]);
    }
    return max(ra, rb);
}
std::vector<ll> minimum_costs(vector<int> H, vector<int> L, vector<int> R) {
    int Q = L.size();
    vector<ll> C(Q);
    int N = 0;
    for (int j = 0; j < Q; ++j) {
        N = max(N, R[j]);
    }
    N++;
    n = N;
    if(Q <= 10 && n <= 3001){
        // sb 1
        for(int i=0; i<N; ++i){
            update(i, H[i]);
        }
        for(int j=0; j<Q; ++j){
            int l = L[j], r = R[j];
            ll ans = 4e18;
            for(int x=l; x<=r; ++x){
                ll cur = 0;
                for(int i=l; i<=r; ++i){
                    cur += query(min(i,x), max(i,x));
                }
                ans = min(ans, cur);
            }
            C[j] = ans;
        }
    
        return C;
    }
    
    
}
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:75:1: warning: control reaches end of non-void function [-Wreturn-type]
   75 | }
      | ^| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |