# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
259202 |
2020-08-07T11:19:51 Z |
Hehehe |
Rice Hub (IOI11_ricehub) |
C++14 |
|
30 ms |
3328 KB |
#include<bits/stdc++.h> //:3
using namespace std;
typedef long long ll;
#define all(a) (a).begin(), (a).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define sz(x) (int)((x).size())
//#define int long long
#include "ricehub.h"
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const ll inf = 2e9;
const ll mod = 1e9 + 7;
const int N = 2e6 + 11;
const ll INF64 = 3e18 + 1;
const double eps = 1e-14;
const double PI = acos(-1);
//ifstream in(".in");
//ofstream out(".out");
ll x[N], s[N];
ll get(int x, int y){
if(x > y)return 0;
return s[y] - s[x - 1];
}
bool ok(int k, int n, ll b){
for(int l = 1; l <= n - k + 1; l++){
int r = l + k - 1;
int m = (l + r) >> 1; //location
ll cur = 0;
cur = x[m]*(m - l) - get(l, m - 1);
cur += get(m + 1, r) - x[m]*(r - m);
if(cur <= b)return 1;
}
return 0;
}
int besthub (int n, int L, int X[], ll b){
for(int i = 1; i <= n; i++){
x[i] = X[i - 1];
}
for(int i = 1; i <= n; i++){
s[i] = s[i - 1] + x[i];
}
ll l = 1, r = n, ans = 1;
while(l <= r){
int mid = (l + r) >> 1;
if(ok(mid, n, b)){
ans = mid;
l = mid + 1;
}else r = mid - 1;
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
0 ms |
384 KB |
Output is correct |
12 |
Correct |
0 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
0 ms |
384 KB |
Output is correct |
15 |
Correct |
0 ms |
384 KB |
Output is correct |
16 |
Correct |
1 ms |
384 KB |
Output is correct |
17 |
Correct |
0 ms |
384 KB |
Output is correct |
18 |
Correct |
0 ms |
384 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
0 ms |
384 KB |
Output is correct |
21 |
Correct |
1 ms |
384 KB |
Output is correct |
22 |
Correct |
0 ms |
384 KB |
Output is correct |
23 |
Correct |
1 ms |
384 KB |
Output is correct |
24 |
Correct |
1 ms |
384 KB |
Output is correct |
25 |
Correct |
1 ms |
384 KB |
Output is correct |
26 |
Correct |
1 ms |
384 KB |
Output is correct |
27 |
Correct |
1 ms |
384 KB |
Output is correct |
28 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
0 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
0 ms |
384 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
1 ms |
384 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
1 ms |
512 KB |
Output is correct |
22 |
Correct |
1 ms |
512 KB |
Output is correct |
23 |
Correct |
1 ms |
512 KB |
Output is correct |
24 |
Correct |
2 ms |
512 KB |
Output is correct |
25 |
Correct |
1 ms |
512 KB |
Output is correct |
26 |
Correct |
1 ms |
512 KB |
Output is correct |
27 |
Correct |
1 ms |
512 KB |
Output is correct |
28 |
Correct |
1 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
768 KB |
Output is correct |
2 |
Correct |
4 ms |
896 KB |
Output is correct |
3 |
Correct |
18 ms |
3320 KB |
Output is correct |
4 |
Correct |
18 ms |
3328 KB |
Output is correct |
5 |
Correct |
14 ms |
1664 KB |
Output is correct |
6 |
Correct |
9 ms |
1716 KB |
Output is correct |
7 |
Correct |
16 ms |
3072 KB |
Output is correct |
8 |
Correct |
16 ms |
3072 KB |
Output is correct |
9 |
Correct |
9 ms |
1664 KB |
Output is correct |
10 |
Correct |
9 ms |
1664 KB |
Output is correct |
11 |
Correct |
30 ms |
3328 KB |
Output is correct |
12 |
Correct |
20 ms |
3328 KB |
Output is correct |
13 |
Correct |
16 ms |
1664 KB |
Output is correct |
14 |
Correct |
10 ms |
1664 KB |
Output is correct |
15 |
Correct |
14 ms |
2560 KB |
Output is correct |
16 |
Correct |
15 ms |
2688 KB |
Output is correct |
17 |
Correct |
19 ms |
3064 KB |
Output is correct |
18 |
Correct |
17 ms |
3072 KB |
Output is correct |
19 |
Correct |
19 ms |
3200 KB |
Output is correct |
20 |
Correct |
18 ms |
3200 KB |
Output is correct |