제출 #614086

#제출 시각아이디문제언어결과실행 시간메모리
614086chirathnirodha모임들 (IOI18_meetings)C++17
19 / 100
5560 ms5688 KiB
#include "meetings.h" #include<bits/stdc++.h> using namespace std; #define PB push_back #define MP make_pair #define F first #define S second #define P push typedef long long ll; vector<ll> minimum_costs(vector<int> H, vector<int> L,vector<int> R) { int n,q; n=H.size();q=L.size(); vector<ll> hei; for(int i=0;i<n;i++)hei.PB((ll)H[i]); vector<ll> C; for(int h=0;h<q;h++){ ll ans=INT64_MAX; ll vall[n],valr[n]; vector<int> v; ll cur=hei[L[h]];vall[L[h]]=cur; v.PB(L[h]); for(int i=L[h]+1;i<=R[h];i++){ while(!v.empty()){ int last=v.back(); if(hei[last]>=hei[i])break; v.pop_back(); if(v.empty())cur+=(hei[i]-hei[last])*(last-L[h]+1); else cur+=(hei[i]-hei[last])*(last-v.back()); } v.PB(i);cur+=hei[i]; vall[i]=cur; } v.clear(); cur=hei[R[h]];valr[R[h]]=cur; v.PB(R[h]); for(int i=R[h]-1;i>=L[h];i--){ while(!v.empty()){ int last=v.back(); if(hei[last]>=hei[i])break; v.pop_back(); if(v.empty())cur+=(hei[i]-hei[last])*(R[h]-last+1); else cur+=(hei[i]-hei[last])*(v.back()-last); } v.PB(i);cur+=hei[i]; valr[i]=cur; } for(int i=L[h];i<=R[h];i++){ ans=min(ans,vall[i]+valr[i]-hei[i]); } C.PB(ans); } return C; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...