답안 #972517

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
972517 2024-04-30T14:13:36 Z rahidilbayramli 쌀 창고 (IOI11_ricehub) C++17
0 / 100
3 ms 604 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)
{
    int 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 = (l + mid) / 2;
            ll sum1 = pref[i] - pref[max(0LL, idx - 2)];
            ll sum2 = pref[idx] - pref[mid - 1];
            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();
    }
}
*/
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -