Submission #139472

# Submission time Handle Problem Language Result Execution time Memory
139472 2019-07-31T20:13:15 Z Sorting Rice Hub (IOI11_ricehub) C++14
0 / 100
67 ms 740 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 7;

long long b;
int l, r, *x;
long long prefix[N];

long long calc_sum(int from, int to){
	if(from == 0){
		return prefix[to];
	}
	return prefix[to] - prefix[from - 1];
}

long long find_score(int from, int to){
	long long mid;

	if((to - from) & 1){
		mid = (x[(to + from) / 2] + x[(to + from) / 2 + 1]) / 2;
	}
	else{
		mid = x[(to + from) / 2];
	}

	long long ans = ((to + from) / 2 - from + 1ll) * mid - calc_sum(from, (to + from) / 2);
	ans += calc_sum((to + from) / 2 + 1, to) - (to - (to + from) / 2ll) * mid;

	return ans;
}

int besthub(int _r, int _l, int *_x, long long _b){
	r = _r;
	l = _l;
	x = _x;
	b = _b;

	int ans = 0;

	prefix[0] = x[0];
	for(int i = 1; i < r; i++){
		prefix[i] = x[i] + prefix[i - 1];
	}

	for(int i = 0; i < r; i++){
		int j;

		for(j = i; j < r && (x[j] - x[i]) <= 2 * b; j++);
		j--;
		ans = max(ans, j - i + 1);
	}

	return ans;
}	
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Incorrect 2 ms 376 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 380 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 67 ms 740 KB Output isn't correct
2 Halted 0 ms 0 KB -