Submission #235809

# Submission time Handle Problem Language Result Execution time Memory
235809 2020-05-30T02:26:18 Z Masterdan Rice Hub (IOI11_ricehub) C++14
0 / 100
7 ms 768 KB
#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 double db;
int besthub(int n, int L, int X[], ll cash)
{
    vi v;
    for(int i=0;i<n;i++){
        v.pb(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;
    }*/
    int in=0,fin=0;
    int 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;
}*/
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 768 KB Output isn't correct
2 Halted 0 ms 0 KB -