#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;
#define db long double
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define endl '\n'
#define all(x) x.begin(), x.end()
#define fastio\
ios_base::sync_with_stdio(0);\
cin.tie(0);\
cout.tie(0)\
ll pre[100005];
int besthub(int n, int m, int a[], long long c){
for(int i = 1; i <= n; i++){
pre[i] = pre[i - 1] + a[i];
}
ll l = 1, r = n, res = 0;
while(l <= r){
ll mid = (l + r) / 2, f = 0;
for(ll i = 1; i <= n; i++){
if(i + mid - 1 > n) break;
ll midd = (i + i + mid - 1) / 2;
ll cost = -(pre[midd] - pre[i - 1]) + a[midd] * (midd - i + 1) + (pre[i + mid - 1] - pre[midd]) - (i + mid - 1 - midd) * a[midd];
if(cost <= c){
f = 1;
}
}
if(f){
res = mid;
l = mid + 1;
}
else{
r = mid - 1;
}
}
return res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
2392 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |