Submission #765753

#TimeUsernameProblemLanguageResultExecution timeMemory
765753t6twotwoMeetings (IOI18_meetings)C++17
0 / 100
266 ms1504 KiB
#include "meetings.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll inf = 1e18;
vector<ll> minimum_costs(vector<int> H, vector<int> L, vector<int> R) {
    int N = H.size(), Q = L.size();
    vector<ll> ans(Q);
    for (int i = 0; i < Q; i++) {
        int T = L[i];
        for (int j = L[i]; j <= R[i]; j++) {
            if (H[j] < H[T]) {
                T = j;
            }
        }
        int mx = H[T];
        for (int j = T; j <= R[i]; j++) {
            mx = max(mx, H[j]);
            ans[i] += mx;
        }
        mx = H[T];
        for (int j = T; j >= L[i]; j--) {
            mx = max(mx, H[j]);
            ans[i] += mx;
        }
        ans[i] -= H[T];
    }
    return ans;
}

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:7:9: warning: unused variable 'N' [-Wunused-variable]
    7 |     int N = H.size(), Q = L.size();
      |         ^
#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...