# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
152872 | Segtree | Meetings (IOI18_meetings) | C++14 | 2 ms | 468 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<iostream>
#include<algorithm>
#include<vector>
#include<stack>
using namespace std;
typedef long long ll;
#define mod 1000000007
vector<ll> minimum_costs(vector<int> H,vector<int> L,vector<int> R){
vector<ll> anss;
for(int i=0;i<L.size();i++){
ll res[5010];
stack<pair<ll,ll> >s,t;
ll sum=0;
for(int k=L[i];k<=R[i];k++){
ll cnt=0;
while(!s.empty()&&s.top().first<=H[k]){
cnt+=s.top().second;
sum-=s.top().first*s.top().second;
s.pop();
}
if(cnt>0||k==L[i]){
s.push(make_pair(H[k],cnt+1));
sum+=H[k]*(cnt+1);
}
res[k]=sum;
}
while(!s.empty()){
s.pop();
}
sum=0;
for(int k=R[i];k>=L[i];k--){
ll cnt=0;
while(!s.empty()&&s.top().first<=H[k]){
cnt+=s.top().second;
sum-=s.top().first*s.top().second;
s.pop();
}
if(cnt>0||k==L[i]){
s.push(make_pair(H[k],cnt+1));
sum+=H[k]*(cnt+1);
}
res[k]+=sum;
}
ll ans=0;
for(int k=L[i];k<=R[i];k++){
ans=max(ans,res[k]);
}
anss.push_back(ans);
}
return anss;
}/*
int main(){
return 0;
}*/
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... |