#include "ricehub.h"
#include <bits/stdc++.h>
#define MAX 1e9+7
#define PI 3.141592653589
#define pb push_back
#define mk make_pair
#define F first
#define S second
#define MIN -1
#define SMAX 1e18+7
#define all(a) a.begin (), a.end ()
using namespace std;
typedef long long int ll;
typedef vector <int> vi;
typedef pair<int, int> ii;
typedef vector<ll> vll;
typedef double db;
int besthub(int n, int L, int X[], ll cash)
{
vll v;
for(int i=0;i<n;i++){
v.pb(ll(X[i]));
}
//vi v1=v;
//sort(all(v1));
/* ll in=1, fin=cash+1;
while(in!=fin){
ll mid=(in+fin)/2;
ll totalaux=0;
for(int i=0;i<v1.size ();i++){
ll aux=(abs(mid-v[i]));
totalaux+=aux;
}
if(totalaux>cash)totalaux=0;
int midfin=(mid+1+fin)/2;
for(int i=0;i<v1.size ();i++){
int aux=abs(midfin-v[i]);
}
int midin=(in+mid)/2;
}*/
ll in=0,fin=0;
ll totalaux=0,mid=0,flag=1,total=1;
while(fin<n){
//if(fin>=n)break;
if(totalaux>cash){
totalaux=totalaux-v[mid]-v[in];in++;
if(flag%2==1)mid++;
flag--;
}
else{
fin++;
totalaux=totalaux+v[fin]-v[mid];total=max(total,flag);
if(flag%2==1)mid++;
flag++;
}
}
return total;
}
/*
static int R, L;
static long long B;
static int X[MAX_R];
static int solution;
inline
void my_assert(int e) {if (!e) abort();}
static void read_input()
{
int i;
my_assert(3==scanf("%d %d %lld",&R,&L,&B));
for(i=0; i<R; i++)
my_assert(1==scanf("%d",&X[i]));
my_assert(1==scanf("%d",&solution));
}
int main()
{
int ans;
read_input();
ans = besthub(R,L,X,B);
if(ans==solution)
printf("Correct.\n");
else
printf("Incorrect. Returned %d instead of %d.\n",ans,solution);
return 0;
}*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
8 ms |
816 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |