Submission #233111

# Submission time Handle Problem Language Result Execution time Memory
233111 2020-05-19T11:28:57 Z crossing0ver Rice Hub (IOI11_ricehub) C++17
0 / 100
1000 ms 512 KB
#include<bits/stdc++.h>
#include "ricehub.h"
using namespace std;
int besthub(int n, int L, int X[], long long B){ 
	long long sum = 0;
	int num = 0;
	int last = 0;
	vector<long long> PR(n);
	int ans = 0,ps = 0;
	for (int i = 0 ; i < n; i++) {
		sum += X[i];
		PR[i] = sum;
		num++;
		while (true) {
		long long  e = sum/num;
		int pos = lower_bound(X + last, X + i, e) - X;
		long long D = 0;
		long long s = X[pos]*(pos - last + 1) - (PR[pos] - (last ? PR[last-1] : 0)) - (PR[i] - PR[pos]) -X[pos]*( i - pos);
		if (s <= B)
		if (ans < i - last + 1) 
			ans = i - last + 1, ps = X[pos];
		D = s;
		if (pos < i) {
		pos++;
		s =X[pos]*(pos - last + 1) - (PR[pos] - (last ? PR[last-1] : 0)) - (PR[i] - PR[pos]) -X[pos]*( i - pos);
		D = min(D,s);
			if (s <= B)
		if (ans < i - last + 1) 
			ans = i - last + 1, ps = X[pos];
		if (D > B) {
			last++;
			num--;
			continue;
		}
		else break;
		}
	}
	} 
    return ps;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 1087 ms 256 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1087 ms 384 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1088 ms 256 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1090 ms 512 KB Time limit exceeded
2 Halted 0 ms 0 KB -