Submission #739957

# Submission time Handle Problem Language Result Execution time Memory
739957 2023-05-11T18:27:22 Z swagchicken Rice Hub (IOI11_ricehub) C++14
0 / 100
3 ms 976 KB
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef vector<int> vi;
typedef vector< vector <int> > vvi;
typedef pair<int, int> pii;
typedef pair < pair < int, int >, int > piii;
typedef pair < pair <int, int > , pair <int, int> > piiii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
 
#define FOR(i,a,b) for(int i = a; i < b; i ++)
#define RFOR(i,a,b) for(int i = a-1; i >= b; i --)
#define all(a) a.begin(), a.end()
#define endl '\n';
#define sz(x) (int)(x).size()
 
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
 

int r; 
vector<ll> x;
vector<ll> pre;
ll l;
ll b;

bool test(int k) {
    FOR(i,0,r-k+1) {
        int mid = (i + i + k - 1)/2;
        
        ll lft = mid - i + 1;
        ll rgt = (i + k - 1) - mid;

       // cout << lft << " " << rgt << endl;

        ll tot = lft * x[mid] - (pre[mid+1] - pre[i]) + (pre[i + k] - pre[mid + 1]) - rgt * x[mid];
        if(tot <= b) {
            cout << i << " " << i + k-1 <<endl;
            return true;
        }
    }
    return false;
}

int besthub(int R, int L, int X[], ll B) {
    r = R;
    FOR(i,0,r) x.pb(X[i]);
    l = L;
    b = B;

    pre.resize(r+1);
    FOR(i,1,r+1) {
        pre[i] = x[i-1] + pre[i-1];
    }

    int lo = 1;
    int hi = r;
    while(lo != hi) {
        int mid = (lo + hi + 1)/2;

        bool good = test(mid);
        if(good) {
            lo = mid;
        } else {
            hi = mid-1;
        }
    }
    return lo;
}


# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 976 KB Output isn't correct
2 Halted 0 ms 0 KB -