Submission #948835

# Submission time Handle Problem Language Result Execution time Memory
948835 2024-03-18T15:10:12 Z steveonalex Rice Hub (IOI11_ricehub) C++14
0 / 100
3 ms 860 KB
#include <bits/stdc++.h>
#include "ricehub.h"
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define MASK(i) (1ULL << (i))
#define GETBIT(mask, i) (((mask) >> (i)) & 1)
#define ALL(v) (v).begin(), (v).end()
 
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
 
ll LASTBIT(ll mask){return (mask) & (-mask);}
int pop_cnt(ll mask){return __builtin_popcountll(mask);}
int ctz(ull mask){return __builtin_ctzll(mask);}
int logOf(ull mask){return 63 - __builtin_clzll(mask);}
 
mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
ll rngesus(ll l, ll r){return l + (ull) rng() % (r - l + 1);}
 
template <class T1, class T2>
    bool maximize(T1 &a, T2 b){
        if (a < b) {a = b; return true;}
        return false;
    }
 
template <class T1, class T2>
    bool minimize(T1 &a, T2 b){
        if (a > b) {a = b; return true;}
        return false;
    }
 
template <class T>
    void printArr(T& container, string separator = " ", string finish = "\n", ostream &out = cout){
        for(auto item: container) out << item << separator;
        out << finish;
    }
 
template <class T>
    void remove_dup(vector<T> &a){
        sort(ALL(a));
        a.resize(unique(ALL(a)) - a.begin());
    }

int besthub(int n, int L, int X[], ll B){
    vector<ll> a(n+1);
    for(int i= 0; i<n; ++i) a[i+1] = X[i];
    vector<ll> pref = a;
    for(int i = 1; i<=n; ++i) pref[i] += pref[i-1];

    int l = 1, r = n;
    while(l < r){
        int mid = (l + r + 1) >> 1;
        bool check = false;
        for(int i = mid; i <= n; ++i){
            int l = i - mid + 1, r = i, x = (l + r) >> 1;
            ll cur = a[x] * (x - l + 1) - (pref[x] - pref[l-1]) + (pref[r] - pref[x]) - a[x] * (r - x);
        }
        if (check) l = mid;
        else r = mid - 1;
    }
    return l;
}


// int main(void){
//     ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

//     return 0;
// }

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, ll)':
ricehub.cpp:60:16: warning: unused variable 'cur' [-Wunused-variable]
   60 |             ll cur = a[x] * (x - l + 1) - (pref[x] - pref[l-1]) + (pref[r] - pref[x]) - a[x] * (r - x);
      |                ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 0 ms 444 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 1 ms 444 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 860 KB Output isn't correct
2 Halted 0 ms 0 KB -