# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1099531 |
2024-10-11T14:29:49 Z |
KasymK |
Rice Hub (IOI11_ricehub) |
C++17 |
|
14 ms |
3092 KB |
#include "bits/stdc++.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define tr(i, c) for(auto i = c.begin(); i != c.end(); ++i)
#define wr puts("----------------")
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
const int N = 1e5+5;
ll par[N];
int besthub(int rr, int L, int x[], ll b){
par[0] = 0;
for(int i = 1; i <= rr; ++i)
par[i] = par[i-1]+x[i-1];
auto eday = [&](int s, int t) -> ll {
int p = (s+t)>>1;
ll wow = (p-s)*x[p]-(par[p]-par[s])+(par[t+1]-par[p+1])-(t-p)*x[p];
return wow;
};
auto calc = [&](int k) -> bool {
deque<int> dq;
for(int i = 0; i <= k; ++i)
dq.pb(i);
int s = dq.front(), t = dq.back();
bool done = 0;
done |= eday(s, t) <= b;
for(int i = k+1; i < rr and !done; ++i)
dq.pop_front(), dq.pb(i), s = dq.front(), t = dq.back(), done |= eday(s, t) <= b;
return done;
};
int l = 0, r = rr-1, answer = -1;
while(l <= r){
int mid = (l+r)>>1;
if(calc(mid))
l = mid+1, answer = mid+1;
else
r = mid-1;
}
return answer;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
392 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
440 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
448 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
596 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
456 KB |
Output is correct |
26 |
Correct |
1 ms |
344 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
860 KB |
Output is correct |
2 |
Correct |
3 ms |
712 KB |
Output is correct |
3 |
Correct |
13 ms |
3092 KB |
Output is correct |
4 |
Correct |
13 ms |
3080 KB |
Output is correct |
5 |
Correct |
7 ms |
1248 KB |
Output is correct |
6 |
Correct |
6 ms |
1372 KB |
Output is correct |
7 |
Correct |
11 ms |
2716 KB |
Output is correct |
8 |
Correct |
11 ms |
2716 KB |
Output is correct |
9 |
Correct |
6 ms |
1376 KB |
Output is correct |
10 |
Correct |
6 ms |
1372 KB |
Output is correct |
11 |
Correct |
14 ms |
3088 KB |
Output is correct |
12 |
Correct |
12 ms |
3080 KB |
Output is correct |
13 |
Correct |
6 ms |
1432 KB |
Output is correct |
14 |
Correct |
6 ms |
1372 KB |
Output is correct |
15 |
Correct |
9 ms |
2416 KB |
Output is correct |
16 |
Correct |
9 ms |
2392 KB |
Output is correct |
17 |
Correct |
12 ms |
2792 KB |
Output is correct |
18 |
Correct |
12 ms |
2792 KB |
Output is correct |
19 |
Correct |
12 ms |
2868 KB |
Output is correct |
20 |
Correct |
12 ms |
2920 KB |
Output is correct |