Submission #55848

# Submission time Handle Problem Language Result Execution time Memory
55848 2018-07-09T05:51:34 Z leejseo Rice Hub (IOI11_ricehub) C++
68 / 100
28 ms 1792 KB
#include "ricehub.h"
#include <algorithm>
using namespace std;

long long S[1000001];

inline long long val(int i){
	return i<0? 0 : S[i];
}

inline long long cost(int i, int j, int X[]){
	int mid = i+j >> 1;
	long long left = X[mid] * (mid - i) - (val(mid-1) - val(i-1));
	long long right = val(j) - val(mid) - X[mid] * (j - mid);
	return left + right;
}

int besthub(int R, int L, int X[], long long B){
	S[0] = X[0];
	for (int i=1; i<R; i++) S[i] = S[i-1] + X[i];
  int ans = 0;
	int i=0, j=0;
	while (i < R && j < R){
		if (cost(i, j, X) > B){
			i++;
			continue;
		}
		ans = max(ans, j-i+1);
		j++;
	}
	return ans;
}

Compilation message

ricehub.cpp: In function 'long long int cost(int, int, int*)':
ricehub.cpp:12:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  int mid = i+j >> 1;
            ~^~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 2 ms 488 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 488 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 3 ms 520 KB Output is correct
6 Correct 2 ms 576 KB Output is correct
7 Correct 3 ms 576 KB Output is correct
8 Correct 2 ms 576 KB Output is correct
9 Correct 2 ms 576 KB Output is correct
10 Correct 2 ms 576 KB Output is correct
11 Correct 3 ms 576 KB Output is correct
12 Correct 2 ms 576 KB Output is correct
13 Correct 2 ms 576 KB Output is correct
14 Correct 2 ms 576 KB Output is correct
15 Correct 2 ms 576 KB Output is correct
16 Correct 2 ms 576 KB Output is correct
17 Correct 2 ms 576 KB Output is correct
18 Correct 2 ms 576 KB Output is correct
19 Correct 2 ms 576 KB Output is correct
20 Correct 2 ms 576 KB Output is correct
21 Correct 3 ms 604 KB Output is correct
22 Correct 3 ms 604 KB Output is correct
23 Correct 3 ms 604 KB Output is correct
24 Correct 2 ms 604 KB Output is correct
25 Correct 2 ms 604 KB Output is correct
26 Correct 2 ms 604 KB Output is correct
27 Correct 2 ms 604 KB Output is correct
28 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 604 KB Output is correct
2 Correct 2 ms 604 KB Output is correct
3 Correct 2 ms 604 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Correct 2 ms 604 KB Output is correct
6 Correct 2 ms 604 KB Output is correct
7 Correct 2 ms 604 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 3 ms 620 KB Output is correct
11 Correct 2 ms 744 KB Output is correct
12 Correct 2 ms 744 KB Output is correct
13 Correct 2 ms 744 KB Output is correct
14 Correct 2 ms 744 KB Output is correct
15 Correct 3 ms 744 KB Output is correct
16 Correct 2 ms 744 KB Output is correct
17 Correct 2 ms 744 KB Output is correct
18 Correct 2 ms 744 KB Output is correct
19 Correct 3 ms 744 KB Output is correct
20 Correct 2 ms 744 KB Output is correct
21 Correct 2 ms 744 KB Output is correct
22 Correct 4 ms 744 KB Output is correct
23 Correct 3 ms 744 KB Output is correct
24 Correct 3 ms 744 KB Output is correct
25 Correct 4 ms 744 KB Output is correct
26 Correct 4 ms 744 KB Output is correct
27 Correct 3 ms 744 KB Output is correct
28 Correct 4 ms 744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 748 KB Output is correct
2 Correct 6 ms 748 KB Output is correct
3 Correct 28 ms 1788 KB Output is correct
4 Correct 20 ms 1788 KB Output is correct
5 Correct 10 ms 1788 KB Output is correct
6 Correct 10 ms 1788 KB Output is correct
7 Correct 15 ms 1788 KB Output is correct
8 Correct 16 ms 1788 KB Output is correct
9 Correct 9 ms 1788 KB Output is correct
10 Correct 10 ms 1788 KB Output is correct
11 Correct 19 ms 1792 KB Output is correct
12 Correct 26 ms 1792 KB Output is correct
13 Correct 9 ms 1792 KB Output is correct
14 Correct 9 ms 1792 KB Output is correct
15 Correct 17 ms 1792 KB Output is correct
16 Correct 17 ms 1792 KB Output is correct
17 Correct 24 ms 1792 KB Output is correct
18 Incorrect 17 ms 1792 KB Output isn't correct
19 Halted 0 ms 0 KB -