Submission #199791

# Submission time Handle Problem Language Result Execution time Memory
199791 2020-02-03T12:23:25 Z aer0park Rice Hub (IOI11_ricehub) C++14
0 / 100
9 ms 504 KB
#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)
{
	cin>>r>>l>>b;
	for(int i=1;i<=r;i++)
		cin>>x[i];
	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||x[i]-x[st.front()]>=x[cnt]-x[i]))
			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
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -