#include <bits/stdc++.h>
#define ll long long
using namespace std;
vector<int> arr;
bool check(int val, int n, ll B){
for(int i = 1;i<=n-val;++i){
int r = i+val-1;
int m = (i+r)/2;
ll geld;
if((r-i)%2 == 0){
geld = (arr[r]-arr[m])-(arr[m]-arr[i-1]);
}
else{
geld = (arr[r]-arr[m])-(arr[m-1]-arr[i-1]);
}
if(geld <= B) return true;
}
return false;
}
int besthub(int R, int L, int X[], ll B){
arr.resize(R+1); arr[0] = 0;
for(int i = 1;i<=R;++i){
arr[i] = arr[i-1]+X[i-1];
}
int l = 1, r = R;
while(l < r){
//cout << l << " " << r << "\n";
int mid = (l+r)/2;
if(check(mid,R,B)){
l = mid;
}
else{
r = mid-1;
}
}
return l;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
312 KB |
Output is correct |
2 |
Correct |
1 ms |
308 KB |
Output is correct |
3 |
Execution timed out |
1072 ms |
212 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1044 ms |
212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
596 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |