#include<bits/stdc++.h>
using namespace std;
int besthub(int n,int l,int x[],long long b){
long long cost;
int mid,ans=0;
vector<long long> prefixSum(l,0);
for(int i=1;i<=n;i++)prefixSum[i] = prefixSum[i-1]+x[i-1];
//for(int i=1;i<=n;i++)cout<<prefixSum[i]<<" "; cout<<endl;
for(int st=1;st<=n;st++){
for(int en=st;en<=n;en++){
mid = (st+en)/2;
cost = (mid-st)*x[mid]-(prefixSum[mid-1]-prefixSum[st-1]) + (prefixSum[en]-prefixSum[mid])-(en-mid)*x[mid];
if(cost <= b)ans = max(ans,en-st+1);
//cout<<st<<" "<<en<<" "<<cost<<endl;
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
484 ms |
1108 KB |
Output is correct |
2 |
Incorrect |
493 ms |
1108 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |