Submission #225647

# Submission time Handle Problem Language Result Execution time Memory
225647 2020-04-21T02:31:52 Z chubyxdxd Rice Hub (IOI11_ricehub) C++11
Compilation error
0 ms 0 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

/tmp/ccnbFDDE.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccU554nE.o:ricehub.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status