Submission #1003393

# Submission time Handle Problem Language Result Execution time Memory
1003393 2024-06-20T09:39:38 Z vjudge1 Rice Hub (IOI11_ricehub) C++17
100 / 100
17 ms 3420 KB
#pragma GCC optimize("-O3")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include "ricehub.h"
#define ll long long
#define ld long double
#define vl vector<ll>
#define vi vector<int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb push_back
#define p_b pop_back
#define f first
#define s second
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int besthub(int R, int L, int X[], long long B)
{
    ll n = R, i, res = 0;
    ll h[n+5], pref[n+5];
    pref[0] = 0;
    for(i = 1; i <= n; i++)
    {
        h[i] = X[i-1];
        pref[i] = pref[i-1] + h[i];
    }
    for(i = 1; i <= n; i++)
    {
        ll l = i, r = n;
        while(l <= r)
        {
            ll mid = (l + r) / 2;
            ll idx = (i + mid) / 2;
            ll sum1 = pref[idx-1] - pref[i-1];
            ll sum2 = pref[mid] - pref[idx-1];
            ll sum = (h[idx] * (idx - i) - sum1) + (sum2 - (mid - idx + 1) * h[idx]);
            if(sum <= B)
            {
                res = max(res, mid - i + 1);
                l = mid + 1;
            }
            else
                r = mid - 1;
        }
    }
    return res;
}
# 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 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# 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 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 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 444 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 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 0 ms 444 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 604 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
# 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 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 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 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 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 392 KB Output is correct
19 Correct 0 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 496 KB Output is correct
26 Correct 1 ms 540 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 2 ms 760 KB Output is correct
2 Correct 2 ms 972 KB Output is correct
3 Correct 17 ms 3416 KB Output is correct
4 Correct 13 ms 3420 KB Output is correct
5 Correct 5 ms 1744 KB Output is correct
6 Correct 5 ms 1624 KB Output is correct
7 Correct 11 ms 3024 KB Output is correct
8 Correct 11 ms 3020 KB Output is correct
9 Correct 6 ms 1628 KB Output is correct
10 Correct 6 ms 1484 KB Output is correct
11 Correct 14 ms 3420 KB Output is correct
12 Correct 13 ms 3420 KB Output is correct
13 Correct 6 ms 1640 KB Output is correct
14 Correct 6 ms 1628 KB Output is correct
15 Correct 9 ms 2608 KB Output is correct
16 Correct 10 ms 2648 KB Output is correct
17 Correct 12 ms 2904 KB Output is correct
18 Correct 11 ms 3160 KB Output is correct
19 Correct 12 ms 3164 KB Output is correct
20 Correct 11 ms 3292 KB Output is correct