이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 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... |