Submission #233121

# Submission time Handle Problem Language Result Execution time Memory
233121 2020-05-19T11:52:26 Z crossing0ver Rice Hub (IOI11_ricehub) C++17
0 / 100
32 ms 2560 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+1, 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;                                   
		pos = upper_bound(X + last, X + i+1, e) - X - 1;
		if (pos <= i && pos >= last) {
		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 ans;
}   /*
main() {
	int n,L;
	long long B;
	cin >> n >> L >> B;   int X[n];
	for (int i = 0; i < n ; i++) cin >> X[i];
	 << besthub(n,L,X,B);
}
					   )           */

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:9:14: warning: variable 'ps' set but not used [-Wunused-but-set-variable]
  int ans = 0,ps = 0;
              ^~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 4 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 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 5 ms 384 KB Output is correct
9 Correct 6 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 256 KB Output is correct
14 Correct 5 ms 256 KB Output is correct
15 Correct 4 ms 256 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Incorrect 5 ms 256 KB Output isn't correct
20 Halted 0 ms 0 KB -
# 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 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Incorrect 5 ms 384 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 11 ms 640 KB Output is correct
2 Correct 8 ms 768 KB Output is correct
3 Correct 27 ms 2560 KB Output is correct
4 Correct 26 ms 2560 KB Output is correct
5 Correct 14 ms 1280 KB Output is correct
6 Correct 14 ms 1280 KB Output is correct
7 Correct 26 ms 2304 KB Output is correct
8 Correct 26 ms 2304 KB Output is correct
9 Correct 16 ms 1152 KB Output is correct
10 Correct 17 ms 1152 KB Output is correct
11 Correct 29 ms 2552 KB Output is correct
12 Incorrect 32 ms 2560 KB Output isn't correct
13 Halted 0 ms 0 KB -