# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
969730 | BestCrazyNoob | Meetings (IOI18_meetings) | C++17 | 5533 ms | 7368 KiB |
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"
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
constexpr int INF = 2e9;
ll solve(vector<int> H) {
vector<ll> ans(H.size(), 0);
vector<int> s;
int curr = 0;
for (int i = 0; i < H.size(); i++) {
while (s.size() >= 1 && H[i] > H[s.back()]) {
const int d = s.size() == 1 ? s.back() + 1 : s.back() - s[s.size()-2];
curr += d * (H[i] - H[s.back()]);
s.pop_back();
}
s.push_back(i);
curr += H[i];
ans[i] = curr;
}
curr = 0;
s.resize(0);
for (int i = H.size()-1; i >= 0; i--) {
while (s.size() >= 1 && H[i] > H[s.back()]) {
const int d = s.size() == 1 ? H.size() - s.back() : s[s.size()-2] - s.back();
curr += d * (H[i] - H[s.back()]);
s.pop_back();
}
s.push_back(i);
ans[i] += curr;
curr += H[i];
}
return *min_element(ans.begin(), ans.end());
}
vector<long long> minimum_costs(vector<int> H, vector<int> L, vector<int> R) {
vector<ll> C(L.size());
for (int q = 0; q < L.size(); q++) {
C[q] = solve(vector<int>(H.begin() + L[q], H.begin() + R[q] + 1));
}
return C;
}
Compilation message (stderr)
# | 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... |