Submission #225648

# Submission time Handle Problem Language Result Execution time Memory
225648 2020-04-21T02:32:23 Z chubyxdxd Rice Hub (IOI11_ricehub) C++11
0 / 100
11 ms 512 KB
#include "ricehub.h"
#include <bits/stdc++.h>
#include <stdio.h>
#include <stdlib.h>

#define MAX_R  1000000
using namespace std;
typedef long long ll;
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 besthub(int R, int L, int x[], long long B){
  ll maxrice=0;
  for(int i=0;i<R;i++){
    ll curr=B;
    ll currrice=0;
    ll lf=i-1,rh=i+1;
    while(lf>=0 and rh<R){
      ll pos=abs(x[i]-x[lf]);
      ll pos1=abs(x[i]-x[rh]);
      if(curr<pos and curr<pos1)break;
      if(pos<pos1){
	curr-=pos;
	lf--;
	currrice++;
      }
      else{
	curr-=pos1;
	rh++;
	currrice++;
      }
    }
    if(lf>=0){
      while(lf>=0){
	ll pos=abs(x[i]-x[lf]);
	if(curr<pos)break;
	curr-=pos;
	currrice++;
	lf--;
      }
    }
    else{
      while(rh<R){
	ll pos1=abs(x[i]-x[rh]);
	if(curr<pos1)break;
	curr-=pos1;
	currrice++;
	rh++;
      }
    }
    maxrice=max(maxrice,currrice);
  }
  return maxrice;
}/*
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;
  }*/

Compilation message

ricehub.cpp:17:13: warning: 'void read_input()' defined but not used [-Wunused-function]
 static void read_input()
             ^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 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 11 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -