Submission #165606

# Submission time Handle Problem Language Result Execution time Memory
165606 2019-11-27T16:26:22 Z Peacher29 Rice Hub (IOI11_ricehub) C++14
100 / 100
39 ms 4216 KB
#include "ricehub.h"
#include<bits/stdc++.h>

using namespace std;

class pont{
public:
	int index;
	long long ut, el;
};

vector<pont> p;

const bool operator<(const pont& p1, const pont& p2){
	return p1.index < p2.index;
}

long long L;

long long mennyi(long long e, long long i, long long u){
	return p[e].ut-p[i].ut-(i-e)*(L-p[i].index)
		  +p[u].el-p[i].el-(u-i)*p[i].index;
}

int besthub(int n, int l, int x[], long long b)
{
	L=l;
	int er=0;
	p.resize(n);
	for(int i=0;i<n;i++){
		p[i].index=x[i];
	}
	sort(p.begin(),p.end());
	p[0].el=p[0].index;
	for(int i=1;i<n;i++){
		p[i].el=p[i-1].el+p[i].index;
	}
	p[n-1].ut=l-p[n-1].index;
	for(int i=n-2;i>=0;i--){
		p[i].ut=p[i+1].ut+l-p[i].index;
	}
	for(int i=0;i<n;i++){
		int aa=i, bb = n-1, k;
		while(aa!=bb){
			k=(aa+bb) /2+1;
			if(mennyi(i, (i+k)/2,k)<=b){
				aa=k;
			} else {
				bb=k-1;
			}
		}
		er=max(er,aa-i+1);
	}
return er;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 380 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 380 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 380 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 252 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 256 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 5 ms 404 KB Output is correct
8 Correct 2 ms 380 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 380 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 3 ms 376 KB Output is correct
22 Correct 3 ms 504 KB Output is correct
23 Correct 4 ms 376 KB Output is correct
24 Correct 3 ms 504 KB Output is correct
25 Correct 3 ms 504 KB Output is correct
26 Correct 3 ms 376 KB Output is correct
27 Correct 3 ms 504 KB Output is correct
28 Correct 4 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 888 KB Output is correct
2 Correct 7 ms 888 KB Output is correct
3 Correct 31 ms 3064 KB Output is correct
4 Correct 30 ms 3064 KB Output is correct
5 Correct 15 ms 2044 KB Output is correct
6 Correct 15 ms 2084 KB Output is correct
7 Correct 28 ms 3960 KB Output is correct
8 Correct 28 ms 3832 KB Output is correct
9 Correct 15 ms 2040 KB Output is correct
10 Correct 16 ms 2040 KB Output is correct
11 Correct 32 ms 4088 KB Output is correct
12 Correct 32 ms 4216 KB Output is correct
13 Correct 16 ms 2040 KB Output is correct
14 Correct 16 ms 2040 KB Output is correct
15 Correct 24 ms 3192 KB Output is correct
16 Correct 24 ms 3192 KB Output is correct
17 Correct 29 ms 3704 KB Output is correct
18 Correct 29 ms 3792 KB Output is correct
19 Correct 31 ms 3984 KB Output is correct
20 Correct 39 ms 3960 KB Output is correct