답안 #972777

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
972777 2024-05-01T07:08:46 Z rahidilbayramli 쌀 창고 (IOI11_ricehub) C++17
0 / 100
16 ms 4444 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[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();
    }
}
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 356 KB Output is correct
2 Incorrect 1 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 Incorrect 1 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 448 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Incorrect 1 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 600 KB Output is correct
2 Correct 4 ms 608 KB Output is correct
3 Correct 16 ms 4444 KB Output is correct
4 Incorrect 14 ms 4444 KB Output isn't correct
5 Halted 0 ms 0 KB -