///~~~LOTA~~~///
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
#define ff first
#define ss second
#define ll long long
#define append push_back
#define pii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define MAXN 100000
ll a[MAXN];
ll b[MAXN];
bool check(ll n,ll l,ll r,vector<ll>& v,ll x){
if(l==r) return 1;
int mid=(l+r)/2;
ll o=a[mid]+b[mid];
o-=a[l]+(v[mid]-v[l])*l;
o-=b[r]+(v[r]-v[mid])*(n-r-1);
if(o>x) return 0;
return 1;
}
int besthub(int n,int m,int X[],ll x){
ll o,p,q;
vector<ll> v;
for(int i=0;i<n;i++)
v.append(X[i]);
a[0]=b[n-1]=o=p=q=0;
for(int i=1;i<n;i++)
a[i]=a[i-1]+i*(v[i]-v[i-1]);
for(int i=n-2;i>=0;i--)
b[i]=b[i+1]+(n-1-i)*(v[i+1]-v[i]);
while(q<=n){
if(check(n,p,q,v,x)){
o=max(o,q-p);
q++;
}
else p++;
}
return o;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Incorrect |
0 ms |
2396 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
0 ms |
2396 KB |
Output is correct |
8 |
Correct |
0 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
0 ms |
2396 KB |
Output is correct |
12 |
Correct |
0 ms |
2396 KB |
Output is correct |
13 |
Correct |
0 ms |
2392 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
0 ms |
2392 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
0 ms |
2396 KB |
Output is correct |
19 |
Correct |
1 ms |
2396 KB |
Output is correct |
20 |
Correct |
1 ms |
2392 KB |
Output is correct |
21 |
Correct |
1 ms |
2396 KB |
Output is correct |
22 |
Correct |
1 ms |
2396 KB |
Output is correct |
23 |
Correct |
1 ms |
2396 KB |
Output is correct |
24 |
Correct |
1 ms |
2396 KB |
Output is correct |
25 |
Correct |
1 ms |
2396 KB |
Output is correct |
26 |
Correct |
1 ms |
2396 KB |
Output is correct |
27 |
Correct |
1 ms |
2396 KB |
Output is correct |
28 |
Correct |
1 ms |
2396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2392 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Incorrect |
0 ms |
2396 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2772 KB |
Output is correct |
2 |
Correct |
2 ms |
2776 KB |
Output is correct |
3 |
Correct |
10 ms |
3540 KB |
Output is correct |
4 |
Correct |
9 ms |
3540 KB |
Output is correct |
5 |
Correct |
5 ms |
3032 KB |
Output is correct |
6 |
Correct |
5 ms |
3032 KB |
Output is correct |
7 |
Correct |
9 ms |
3536 KB |
Output is correct |
8 |
Correct |
9 ms |
3540 KB |
Output is correct |
9 |
Correct |
5 ms |
3032 KB |
Output is correct |
10 |
Correct |
5 ms |
3032 KB |
Output is correct |
11 |
Correct |
10 ms |
3540 KB |
Output is correct |
12 |
Correct |
10 ms |
3540 KB |
Output is correct |
13 |
Incorrect |
5 ms |
3540 KB |
Output isn't correct |
14 |
Halted |
0 ms |
0 KB |
- |