제출 #137003

#제출 시각아이디문제언어결과실행 시간메모리
137003amiratou쌀 창고 (IOI11_ricehub)C++14
68 / 100
1083 ms1784 KiB
#include "ricehub.h" #include <bits/stdc++.h> #define fi first #define se second #define ll long long #define ii pair<ll,ll> using namespace std; int besthub(int R, int L, int X[], long long B) { int ans=0; for (int i = 0; i < R; ++i) { int idx=i,comp=1; ll rem=B; priority_queue<pair<ii,ll>,vector<pair<ii,ll>>,greater<pair<ii,ll> > > q; if(idx-1>=0)q.push({{X[idx]-X[idx-1],idx-1},0}); if(idx+1<R)q.push({{X[idx+1]-X[idx],idx+1},1}); while(!q.empty()){ pair<ii,ll> front =q.top(); q.pop(); ll C=front.fi.fi,id=front.fi.se; if(C>rem)break; rem-=C,comp++; if(front.se&&id+1<R) q.push({{X[id+1]-X[id]+C,id+1},1}); if(!front.se&&id-1>=0) q.push({{X[id]-X[id-1]+C,id-1},0}); } //cerr<<i<<" "<<comp<<"\n"; ans=max(ans,comp); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...