이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "ricehub.h"
#include <bits/stdc++.h>
#define f first
#define s second
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> pi;
 
ll sum,anw,cnt=1;
queue<ll> st,ed;
 
int besthub(int r,int l,int x[],ll b)
{
	for(int i=r;i>=1;i--)
		x[i]=x[i-1];
	x[r+1]=l+1;
	for(int i=1;i<=r;i++)
	{
		sum+=(st.size()-ed.size())*(x[i]-x[i-1]);
		if(!ed.empty()) st.push(ed.front()),ed.pop();
		else st.push(cnt),cnt++;
		if(sum<=b) anw=max(anw,(ll)st.size()+(ll)ed.size());
		while(st.size()>=2&&(sum>b))
			sum-=x[i]-x[st.front()],st.pop();
		while(cnt<=r&&sum+x[cnt]-x[i]<=b)
			ed.push(cnt),sum+=x[cnt]-x[i],cnt++;
		anw=max(anw,(ll)st.size()+(ll)ed.size());
	}
	return anw;
}
| # | 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... |