#include <bits/stdc++.h>
#include <iostream>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> order_set;
mt19937 mt_rand(chrono::high_resolution_clock::now().time_since_epoch().count());
//uniform_int_distribution<int> gen; ///(min, max)
//int random() {return gen(mt_rand);}
const int mxN=1e5+5;
const int mod=998244353;
const int mxlogN=40;
const int mxK=26;
const int inf=2e9;
const int K=600;
#include "ricehub.h"
int besthub(int n, int L, int a[], ll B)
{
int ans=0;
int l=0, r=1;
for(int i=0; i<n; i++)
{
if(i)
{
B+=(r-i)*(a[i]-a[i-1]);
B-=(i-l)*(a[i]-a[i-1]);
}
while(l<i&&r<n&&a[i]-a[l]>a[r]-a[i])
{
B+=a[i]-a[l++];
B-=a[r++]-a[i];
}
while(l<i&&B<0) B+=a[i]-a[l++];
while(r<n&&a[i]>=B) B-=a[r++]-a[i];
ans=max(ans,r-l);
}
return ans;
}
/*
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
}
*/
/*
7 3
4 1 3 4 0 2 3
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
308 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 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
452 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |