# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
294576 | SeDunion | Meetings (IOI18_meetings) | C++14 | 5588 ms | 1572 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 <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e6;
ll p[N], s[N];
vector<ll> minimum_costs (vector<int> H, vector<int> L, vector<int> R) {
int Q = L.size();
vector<ll> C(Q);
for (int query = 0 ; query < Q ; ++ query) {
int l = L[query], r = R[query];
{
ll now = 0;
map <int, ll> mp;
for (int i = l ; i <= r ; ++ i) {
mp[H[i]]++;
now += H[i];
while (mp.size()) {
auto [key, val] = *mp.begin();
if (key >= H[i]) break;
mp.erase (mp.begin());
now -= key * val;
mp[H[i]] += val;
now += H[i] * val;
}
p[i] = now;
}
}
ll ans = p[r];
p[l - 1] = 0;
{
ll now = 0;
map <int, ll> mp;
for (int i = r ; i >= l ; -- i) {
mp[H[i]]++;
now += H[i];
while (mp.size()) {
auto [key, val] = *mp.begin();
if (key >= H[i]) break;
mp.erase (mp.begin());
now -= key * val;
mp[H[i]] += val;
now += H[i] * val;
}
ans = min (now + p[i - 1], ans);
}
}
C[query] = ans;
}
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... |