# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
411569 |
2021-05-25T13:58:30 Z |
jeqcho |
Rice Hub (IOI11_ricehub) |
C++17 |
|
18 ms |
2884 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpi;
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)
#define pb push_back
#define rsz resize
#define sz(x) int(x.size())
#define all(x) begin(x), end(x)
#define fi first
// implementing official solution
// subtask 1,2,3
int R;
int const r=1e5+3;
int X[r];
ll pre[r];
ll B;
bool check(int len)
{
F0R(i,R)
{
int las = i+len-1;
if(las>=R)break;
int mid = (i+las)/2;
ll sumpos = pre[mid]-pre[i];
ll cur=X[mid]*(mid-i)-sumpos;
ll sumneg = pre[las+1]-pre[mid+1];
cur += sumneg-X[mid]*(las-mid);
if(cur<=B)
{
return 1;
}
}
return 0;
}
int besthub(int R1, int L, int X1[], ll B1){
R=R1;
pre[0]=0;
F0R(i,R)
{
X[i]=X1[i];
pre[i+1]=pre[i]+(ll)X[i];
}
B=B1;
int lef=1,rig=R;
int ans=-1;
while(lef<=rig)
{
int mid = (lef+rig)/2;
if(check(mid))
{
lef=mid+1;
ans=mid;
}
else
{
rig=mid-1;
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
23 |
Correct |
1 ms |
216 KB |
Output is correct |
24 |
Correct |
1 ms |
204 KB |
Output is correct |
25 |
Correct |
1 ms |
204 KB |
Output is correct |
26 |
Correct |
1 ms |
204 KB |
Output is correct |
27 |
Correct |
1 ms |
204 KB |
Output is correct |
28 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
2 ms |
332 KB |
Output is correct |
22 |
Correct |
1 ms |
332 KB |
Output is correct |
23 |
Correct |
1 ms |
332 KB |
Output is correct |
24 |
Correct |
1 ms |
332 KB |
Output is correct |
25 |
Correct |
1 ms |
332 KB |
Output is correct |
26 |
Correct |
1 ms |
332 KB |
Output is correct |
27 |
Correct |
2 ms |
332 KB |
Output is correct |
28 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
588 KB |
Output is correct |
2 |
Correct |
4 ms |
588 KB |
Output is correct |
3 |
Correct |
18 ms |
1752 KB |
Output is correct |
4 |
Correct |
17 ms |
1868 KB |
Output is correct |
5 |
Correct |
8 ms |
1004 KB |
Output is correct |
6 |
Correct |
9 ms |
1356 KB |
Output is correct |
7 |
Correct |
15 ms |
2544 KB |
Output is correct |
8 |
Correct |
14 ms |
2636 KB |
Output is correct |
9 |
Correct |
10 ms |
1388 KB |
Output is correct |
10 |
Correct |
8 ms |
1356 KB |
Output is correct |
11 |
Correct |
16 ms |
2884 KB |
Output is correct |
12 |
Correct |
16 ms |
2860 KB |
Output is correct |
13 |
Correct |
9 ms |
1484 KB |
Output is correct |
14 |
Correct |
9 ms |
1464 KB |
Output is correct |
15 |
Correct |
12 ms |
2176 KB |
Output is correct |
16 |
Correct |
12 ms |
2244 KB |
Output is correct |
17 |
Correct |
15 ms |
2620 KB |
Output is correct |
18 |
Correct |
15 ms |
2544 KB |
Output is correct |
19 |
Correct |
17 ms |
2768 KB |
Output is correct |
20 |
Correct |
15 ms |
2764 KB |
Output is correct |