# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
165754 |
2019-11-28T13:01:00 Z |
Hideo |
Rice Hub (IOI11_ricehub) |
C++11 |
|
20 ms |
2936 KB |
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include "ricehub.h"
//#include "grader.cpp"
using namespace std;
#define ll long long
const int N = 1e5 + 7;
int a[N], pr[N], sf[N];
int n, ans;
ll mx;
int solve (int l, int r){
int mid = ((l + r) >> 1) + 1;
ll cost = (pr[mid] - pr[l] - (a[mid] - a[l]) * (l - 1)) + (sf[mid] - sf[r] - (a[r] - a[mid]) * (n - r));
if (cost > mx){
if (a[mid] - a[l] > a[r] - a[mid])
solve(l + 1, r);
else
solve(l, r - 1);
}
else
return r - l + 1;
}
int besthub(int R, int L, int X[], long long B){
n = R; mx = B;
for (int i = 0; i < n; i++){
a[i + 1] = X[i];
pr[i + 1] = pr[i] + i * (a[i + 1] - a[i]);
}
for (int i = n; i >= 1; i--)
sf[i] = sf[i + 1] + (n - i) * (a[i + 1] - a[i]);
return solve(1, n);
}
Compilation message
ricehub.cpp: In function 'int solve(int, int)':
ricehub.cpp:29:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 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 |
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 |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
296 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
888 KB |
Output is correct |
2 |
Correct |
5 ms |
888 KB |
Output is correct |
3 |
Correct |
18 ms |
2936 KB |
Output is correct |
4 |
Incorrect |
20 ms |
2908 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |