Submission #229452

# Submission time Handle Problem Language Result Execution time Memory
229452 2020-05-04T14:25:03 Z kshitij_sodani Rice Hub (IOI11_ricehub) C++17
49 / 100
24 ms 1536 KB
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
typedef long long llo;
#define mp make_pair
#define a first
#define b second
#define pb push_back
#include <ricehub.h>
int besthub(int nn,int coo,int tt[],llo b){
	llo n=(llo)nn;
	llo l,r;
	llo tot=0;
	llo ma=0;
	llo it[n];
	for(int i=0;i<n;i++){
		it[i]=(llo)tt[i];
	}
	for(llo i=0;i<n;i++){
		if(i==0){
			l=0;
			r=-1;
			for(llo j=0;j<n;j++){
				if(tot+it[j]-it[0]<=b){
					tot+=(it[j]-it[0]);
					r+=1;
				}
				else{
					break;
				}
			}
			ma=max(ma,r-l+1);
		}
		else{
		/*	if(it[i]==it[i-1]){
				continue;
			}*/
			tot+=abs(it[i]-it[i-1])*abs(l-i);
			tot-=abs(it[i]-it[i-1])*abs(r-i+1);
			llo llp=l;
			for(int j=llp;j<i;j++){
				if(tot>b){
					tot-=abs(it[j]-it[i]);
					l+=1;
				}
				else{
					break;
				}
			}
			if(r+1<i){
				while(true){
					continue;
				}
			}
			for(llo j=r+1;j<n;j++){
				if(abs(it[j]-it[i])<=abs(it[i]-it[l])){
					r+=1;
					tot+=abs(it[j]-it[i]);
					if(tot>b){
						l+=1;
						tot-=abs(it[i]-it[l-1]);
					}
				}
				else if(abs(it[j]-it[i])+tot<=b){
					r+=1;
					tot+=abs(it[j]-it[i]);
				}
				else{
					break;
				}
			}
			ma=max(ma,r-l+1);
		}

	}

	return ma;
}
/*int main(){
	llo cc[5];
	cc[0]=1;
	cc[1]=2;
	cc[2]=10;
	cc[3]=12;
	cc[4]=14;
	cout<<besthub(5,20,cc,(llo)6)<<endl;
	int r,l;
	llo b;
	cin>>r>>l>>b;
	int ac[r];
	for(int i=0;i<r;i++){
		cin>>ac[i];
	}
	cout<<besthub(r,l,ac,b)<<endl;
 
	return 0;
}*/
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 4 ms 256 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 5 ms 304 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 256 KB Output is correct
11 Correct 4 ms 256 KB Output is correct
12 Correct 4 ms 256 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 256 KB Output is correct
17 Correct 4 ms 256 KB Output is correct
18 Correct 5 ms 256 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 256 KB Output is correct
21 Correct 4 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 4 ms 384 KB Output is correct
24 Correct 4 ms 384 KB Output is correct
25 Correct 4 ms 256 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Incorrect 4 ms 256 KB Output isn't correct
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 4 ms 256 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 256 KB Output is correct
10 Correct 5 ms 256 KB Output is correct
11 Correct 5 ms 256 KB Output is correct
12 Correct 5 ms 256 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 256 KB Output is correct
15 Correct 5 ms 256 KB Output is correct
16 Correct 5 ms 256 KB Output is correct
17 Correct 5 ms 256 KB Output is correct
18 Incorrect 5 ms 256 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 512 KB Output is correct
2 Correct 8 ms 512 KB Output is correct
3 Correct 21 ms 1536 KB Output is correct
4 Correct 21 ms 1536 KB Output is correct
5 Correct 12 ms 896 KB Output is correct
6 Correct 12 ms 896 KB Output is correct
7 Correct 20 ms 1536 KB Output is correct
8 Correct 20 ms 1536 KB Output is correct
9 Correct 11 ms 896 KB Output is correct
10 Correct 11 ms 896 KB Output is correct
11 Correct 23 ms 1536 KB Output is correct
12 Correct 24 ms 1536 KB Output is correct
13 Correct 12 ms 896 KB Output is correct
14 Correct 13 ms 896 KB Output is correct
15 Correct 18 ms 1152 KB Output is correct
16 Correct 19 ms 1204 KB Output is correct
17 Correct 21 ms 1408 KB Output is correct
18 Correct 21 ms 1408 KB Output is correct
19 Correct 22 ms 1408 KB Output is correct
20 Correct 23 ms 1408 KB Output is correct