This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int besthub(int n, int lim, int a[], long long cost)
{
int ans = 0;
for(int i = 0; i < n; i ++){
int l = i, r = i + 1;
ll cur = 0;
int cnt = 0;
while(l >= 0 || r < n){
if((l >= 0 && a[i] - a[l] < a[r] - a[i]) || (r >= n)){
cur += a[i] - a[l];
l --;
}else{
cur += a[r] - a[i];
r ++;
}
if(cur > cost) break;
cnt ++;
}
ans = max(ans, cnt);
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |