Submission #974186

# Submission time Handle Problem Language Result Execution time Memory
974186 2024-05-03T05:11:22 Z rahidilbayramli Rice Hub (IOI11_ricehub) C++17
100 / 100
15 ms 5220 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 v[R+5], pref[R+5];
    for(int i = 1; i <= R; i++)
    {
        v[i] = X[i-1];
        pref[i] = pref[i-1] + v[i];
    }
    int ans = 0;
    for(int i = 1; i <= R; i++)
    {
        int l = i, r = R;
        while(l <= r)
        {
            int mid = (l + r) / 2;
            ll idx = (i + mid) / 2;
            ll sum1 = pref[idx-1] - pref[i-1];
            ll sum2 = pref[mid] - pref[idx];
            ll cost = (v[idx] * (idx - i) - sum1) + (sum2 - v[idx] * (mid - idx));
            if(cost <= B)
            {
                ans = max(ans, mid - i + 1);
                l = mid + 1;
            }
            else
                r = mid - 1;
        }
    }
    return ans;
}
/*
void solve()
{
    int r, l, b;
    cin >> r >> l >> b;
    int x[r];
    for(int i = 0; i < r; i++)
        cin >> x[i];
    cout << besthub(r, l, x, b) << "\n";
}
int main()
{
    ll tests = 1;
    //cin >> tests;
    while(tests--)
    {
        solve();
    }
}
*/
# Verdict Execution time Memory Grader output
1 Correct 1 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
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 444 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 344 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 348 KB Output is correct
13 Correct 1 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 1 ms 348 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 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 444 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 448 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 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 1 ms 344 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 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 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 344 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 348 KB Output is correct
26 Correct 1 ms 348 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 856 KB Output is correct
3 Correct 14 ms 5220 KB Output is correct
4 Correct 14 ms 5212 KB Output is correct
5 Correct 7 ms 3676 KB Output is correct
6 Correct 6 ms 3684 KB Output is correct
7 Correct 13 ms 4956 KB Output is correct
8 Correct 14 ms 4956 KB Output is correct
9 Correct 7 ms 3672 KB Output is correct
10 Correct 7 ms 3672 KB Output is correct
11 Correct 14 ms 5212 KB Output is correct
12 Correct 15 ms 5212 KB Output is correct
13 Correct 7 ms 3676 KB Output is correct
14 Correct 7 ms 3648 KB Output is correct
15 Correct 10 ms 4444 KB Output is correct
16 Correct 12 ms 4444 KB Output is correct
17 Correct 13 ms 4952 KB Output is correct
18 Correct 13 ms 4956 KB Output is correct
19 Correct 14 ms 4956 KB Output is correct
20 Correct 13 ms 4956 KB Output is correct