Submission #402479

# Submission time Handle Problem Language Result Execution time Memory
402479 2021-05-11T18:57:06 Z Jasiekstrz Rice Hub (IOI11_ricehub) C++17
100 / 100
16 ms 2512 KB
#include<bits/stdc++.h>
#include "ricehub.h"
#define fi first
#define se second
using namespace std;
const int NN=1e5;
long long t[NN+10];
void move_med(int l,int r,int &m,long long &w)
{
	if(m==(l+r)/2)
		return;
	w+=(t[m+1]-t[m])*(m-l+1);
	w-=(t[m+1]-t[m])*(r-m);
	m++;
	return;
}
int besthub(int R,int L,int X[],long long B)
{
	for(int i=0;i<R;i++)
		t[i]=X[i];
	int ans=0;
	int l=0,r=0,m=0;
	long long w=0;
	while(l<R)
	{
		if(w>B)
		{
			w-=X[m]-X[l];
			l++;
			move_med(l,r,m,w);
		}
		else
		{
			ans=max(ans,r-l+1);
			r++;
			if(r>=R)
				break;
			w+=X[r]-X[m];
			move_med(l,r,m,w);
		}
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 292 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 2 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 2 ms 332 KB Output is correct
27 Correct 2 ms 332 KB Output is correct
28 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 576 KB Output is correct
2 Correct 4 ms 588 KB Output is correct
3 Correct 15 ms 2480 KB Output is correct
4 Correct 16 ms 2512 KB Output is correct
5 Correct 7 ms 1228 KB Output is correct
6 Correct 9 ms 1208 KB Output is correct
7 Correct 13 ms 2124 KB Output is correct
8 Correct 14 ms 2124 KB Output is correct
9 Correct 7 ms 1100 KB Output is correct
10 Correct 7 ms 1100 KB Output is correct
11 Correct 16 ms 2476 KB Output is correct
12 Correct 15 ms 2476 KB Output is correct
13 Correct 9 ms 1288 KB Output is correct
14 Correct 7 ms 1204 KB Output is correct
15 Correct 12 ms 1868 KB Output is correct
16 Correct 12 ms 1864 KB Output is correct
17 Correct 14 ms 2220 KB Output is correct
18 Correct 14 ms 2252 KB Output is correct
19 Correct 16 ms 2372 KB Output is correct
20 Correct 15 ms 2356 KB Output is correct