제출 #117616

#제출 시각아이디문제언어결과실행 시간메모리
117616Osama_Alkhodairy모임들 (IOI18_meetings)C++17
19 / 100
937 ms786432 KiB
#include <bits/stdc++.h>
#include "meetings.h"
//#include "grader.cpp"
using namespace std;
#define ll long long

const int N = 5001;

ll g[N][N][2];

std::vector<long long> minimum_costs(std::vector<int> H, std::vector<int> L,
                                     std::vector<int> R) {
    int n = H.size();
    int q = L.size();
    for(int i = 0 ; i < n ; i++){
        int x = H[i];
        g[i][i][0] = x;
        for(int j = i - 1 ; j >= 0 ; j--){
            x = max(x, H[j]);
            g[i][j][0] = g[i][j + 1][0] + x;
        }
        x = H[i];
        g[i][i][1] = x;
        for(int j = i + 1 ; j < n ; j++){
            x = max(x, H[j]);
            g[i][j][1] = g[i][j - 1][1] + x;
        }
    }
    vector <ll> ret;
    for(int i = 0 ; i < q ; i++){
        ll ans = 1e18;
        for(int j = L[i] ; j <= R[i] ; j++){
            ans = min(ans, g[j][L[i]][0] + g[j][R[i]][1] - H[j]);
        }
        ret.push_back(ans);
    }
    return ret;
}
#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...