Submission #1327720

#TimeUsernameProblemLanguageResultExecution timeMemory
1327720arman.khachatryanRice Hub (IOI11_ricehub)C++20
17 / 100
1096 ms332 KiB
#include <bits/stdc++.h>
using namespace std;
long long besthub(int r, int l, int* a, long long b){
    int j, k, ans=0, cnt;
    long long c;
    bool bl;
    for(int i=0; i<r; i++){
        j=i-1;
        k=i+1;
        cnt=1;
        c=b;
        bl=true;
        while(c>0 && bl){
            if(0<=j && (k>=r || a[i]-a[j]<=a[k]-a[i])){
                if(c<a[i]-a[j]){
                    bl=false;
                    continue;
                }
                c-=(a[i]-a[j])*1LL;
                j--;
                cnt++;
            }else if(k<r && (j<0 || a[i]-a[j]>=a[k]-a[i]) ){
                if(c<a[k]-a[i]){
                    bl=false;
                    continue;
                }
                c-=(a[k]-a[i])*1LL;
                k++;
                cnt++;
            }
        }
        ans=max(ans, cnt);
    }
    return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...