# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
291642 | TheLorax | Meetings (IOI18_meetings) | C++11 | 5549 ms | 2424 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 <bits/stdc++.h>
#include "meetings.h"
#define F first
#define S second
#define SZ(a) ((int)(a).size())
#define PB push_back
#define ALL(a) (a).begin(), (a).end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> ii;
std::vector<long long> minimum_costs(std::vector<int> h, std::vector<int> l, std::vector<int> r) {
int q = SZ(l), n=SZ(h);
std::vector<long long> c(q);
for(int i=0; i<q; i++){
std::vector<ll> a(r[i]-l[i]+1), b(r[i]-l[i]+1);
map<ll,ll> ma, mb;
for(int j=l[i]; j<=r[i]; j++){
ma[h[j]]++;
a[j-l[i]]=(j>l[i]?a[j-l[i]-1]:0)+h[j];
while (ma.begin()->F!=h[j]) {
ma[h[j]]+=ma.begin()->S;
a[j-l[i]]+=h[j]*ma.begin()->S;
a[j-l[i]]-=ma.begin()->F*ma.begin()->S;
ma.erase(ma.begin()->F);
}
}
for(int j=r[i]; j>=l[i]; j--){
mb[h[j]]++;
b[j-l[i]]=(j<r[i]?b[j-l[i]+1]:0)+h[j];
while (mb.begin()->F!=h[j]) {
mb[h[j]]+=mb.begin()->S;
b[j-l[i]]+=h[j]*mb.begin()->S;
b[j-l[i]]-=mb.begin()->F*mb.begin()->S;
mb.erase(mb.begin()->F);
}
}
for(int j=0; j<r[i]-l[i]+1; j++){
// fprintf(stderr, "%lld %lld\n", a[j], b[j]);
a[j]+=b[j]-h[j+l[i]];
}
sort(ALL(a));
c[i]=a[0];
}
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... |