제출 #935335

#제출 시각아이디문제언어결과실행 시간메모리
935335HuyQuang_re_Zero모임들 (IOI18_meetings)C++14
19 / 100
539 ms257360 KiB
#include <bits/stdc++.h> #define ll long long #define db long double #define maxn 100005 #define II pair <ll,ll> #define III pair <ll,II> #define IV pair <vector <int>,vector <int> > #define IDB pair <db,int> #define TII pair <treap*,treap*> #define fst first #define snd second #define BIT(x,i) ((x>>i)&1) #define pi acos(-1) #define to_radian(x) (x*pi/180.0) #define to_degree(x) (x*180.0/pi) #define Log(x) (31-__builtin_clz((int)x)) #define LogLL(x) (63-__builtin_clzll((ll)x) #include "meetings.h" using namespace std; const ll oo=round(1e18); ll a[maxn],i,j,q,n,up[5005][5005],down[5005][5005]; vector <ll> minimum_costs(vector <int> h,vector <int> L,vector <int> R) { for(int x:h) a[++n]=x; q=L.size(); for(i=0;i<q;i++) L[i]++,R[i]++; vector <ll> res(q); if(n<=5000 && q<=5000) { for(i=1;i<=n;i++) { ll ma=0; for(j=i;j>=1;j--) { ma=max(ma,a[j]); down[i][j]=down[i][j+1]+ma; } ma=0; for(j=i;j<=n;j++) { ma=max(ma,a[j]); up[i][j]=up[i][j-1]+ma; } } for(i=0;i<q;i++) { int l=L[i],r=R[i]; res[i]=oo; for(int u=l;u<=r;u++) res[i]=min(res[i],down[u][l]+up[u][r]-a[u]); } } return res; } /* int main() { freopen("meetings.inp","r",stdin); freopen("meetings.out","w",stdout); vector <int> a,L,R; int k,n,l,r; cin>>n; for(int i=1;i<=n;i++) cin>>k,a.push_back(k); while(cin>>l>>r) L.push_back(l),R.push_back(r); vector <ll> res=minimum_costs(a,L,R); for(int x:res) cout<<x<<'\n'; } */
#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...