Submission #388073

# Submission time Handle Problem Language Result Execution time Memory
388073 2021-04-09T21:48:50 Z Pichon5 Rice Hub (IOI11_ricehub) C++17
0 / 100
4 ms 460 KB
#include "ricehub.h"
#include <bits/stdc++.h>
#define vi vector<int>
#define pb push_back
#define ll long long int
using namespace std;
int besthub(int R, int L, int X[], long long B)
{
    vi v;
    int res=0;
    ll pref[R];
    pref[0]=X[0];
    for(int i=1;i<R;i++){
        pref[i]=pref[i-1]+X[i];
    }
    for(int i=0;i<R;i++){
        int b=i,e=R-1;
        while(b<=e){
            int mid=(b+e)/2;
            /*v.clear();
            for(int l=i;l<=mid;l++){
                v.pb(X[l]);
            }
            int MID=v.size()/2;
            ll aux=0;
            for(int l=0;l<v.size();l++){
                aux+=abs(v[l]-v[MID]);
            }*/
            //esto es para la parte de ariiba
            int MID=(i+mid)/2;
            ll aux=pref[mid];
            if(MID)aux-=pref[MID-1];
            aux-=(mid-MID+1)*X[MID];
            //y aqui para la parte de abajo
            if(MID){
                aux-=pref[MID-1];
                if(i)aux+=pref[i-1];
                aux+=(MID-i+1)*X[MID];
            }
            if(aux<=B){
                res=max(res,mid-i+1);
                b=mid+1;
            }else{
                e=mid-1;
            }
        }
    }
    return res;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Incorrect 0 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 460 KB Output isn't correct
2 Halted 0 ms 0 KB -