Submission #393688

# Submission time Handle Problem Language Result Execution time Memory
393688 2021-04-24T08:53:33 Z Karliver Rice Hub (IOI11_ricehub) C++14
0 / 100
4 ms 576 KB
#include "ricehub.h"
#include <bits/stdc++.h>
#include <fstream>
#define FIXED_FLOAT(x)  std::fixed <<std::setprecision(20) << (x)
#define all(v) (v).begin(), (v).end()
using namespace  std;
#define forn(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
int mod = (ll)1e9 + 7;
#define PI acos(-1)
typedef pair<int, int> pairs;
typedef complex<ll> G;
const int INF = 1e9 + 1;
const int N = 1e6 + 100;
const double eps = 1e-3;
 
 template <typename XPAX>
void ckma(XPAX &x, XPAX y) {
    x = (x < y ? y : x);
}
template <typename XPAX>
void ckmi(XPAX &x, XPAX y) {
    x = (x > y ? y : x);
}

int besthub(int R, int L, int X[], ll B) {
    int l = 0;
    int r = 0;
    vector<ll> sm(R + 1, 0);
    ll cost = 0;
    forn(i, R)sm[i + 1] = X[i] + sm[i - 1];
    auto upd = [&]() {
        int mid = (l + r) / 2;
        cost = 0;
        cost += (mid - l + 1)* 1ll * X[mid];
        cost -= sm[mid + 1] - sm[l];
        cost -= (r - mid + 1) * X[mid];
        cost += sm[r + 1] - sm[mid];
 
 
    };
    int ans = 0;
    while(l < R) {
        while(r < R - 1 && cost <= B) {
            ++r;
            upd();
        }
        if(cost > B) {
            r--;
            upd();
        }
        ckma(ans, r - l + 1);
        ++l;
    }
    return ans;
}
 
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 308 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 576 KB Output isn't correct
2 Halted 0 ms 0 KB -