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>
using namespace std;
#ifndef EVAL
#include "grader.cpp"
#endif
#include "meetings.h"
long long calcscore(int l, int r, int p, std::vector<int> const &H)
{
int mx = 0;
long long sum = 0;
for (int i = p; i <= r; i++)
{
mx = max(mx, H[i]);
sum += mx;
}
mx = 0;
for (int i = p; i >= l; i--)
{
mx = max(mx, H[i]);
sum += mx;
}
sum -= H[p];
return sum;
}
long long findmin(int l, int r, std::vector<int> const &H)
{
long long mx = INT64_MAX;
for (int i = l; i <= r; i++)
{
mx = min(mx, calcscore(l, r, i, H));
}
return mx;
}
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)
{
C[j] = findmin(L[j], R[j], H);
}
return C;
}
# | 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... |