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 "meetings.h"
//Challenge: Accepted
#include <bits/stdc++.h>
using namespace std;
#ifdef zisk
void debug(){cout << endl;}
template<class T, class ... U> void debug(T a, U ... b){cout << a << " ", debug(b...);}
template<class T> void pary(T l, T r) {
while (l != r) cout << *l << " ", l++;
cout << endl;
}
#else
#define debug(...) 0
#define pary(...) 0
#endif
#define ll long long
#define maxn 100005
#define pii pair<int, int>
#define ff first
#define ss second
#define io ios_base::sync_with_stdio(0);cin.tie(0);
const ll inf = 1LL<<30;
int lef[maxn], rig[maxn];
ll ls[maxn], rs[maxn];
std::vector<long long> minimum_costs(std::vector<int> H, std::vector<int> L,
std::vector<int> R) {
int q = L.size();
vector<ll> ret(q, 0);
for (int id = 0;id < q;id++) {
vector<int> h;
h.push_back(1<<30);
for (int i = L[id];i <= R[id];i++) h.push_back(H[i]);
h.push_back(1<<30);
int n = h.size() - 2;
ll ans = inf;
for (int i = 1;i <=n;i++) {
ll cur = 0;
int ma = h[i];
for (int j = i;j >= 1;j--) {
ma = max(ma, h[j]);
cur += ma;
}
ma = h[i];
for (int j = i + 1;j <= n;j++) {
ma = max(ma, h[j]);
cur += ma;
}
ans = min(ans, cur);
}
ret[id] = ans;
}
return ret;
}
/*
4 2
2 4 3 5
0 2
1 3
*/
# | 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... |