Submission #1247878

#TimeUsernameProblemLanguageResultExecution timeMemory
1247878LM1Rice Hub (IOI11_ricehub)C++20
Compilation error
0 ms0 KiB
#include "ricehub.h"
#include <stdio.h>
#include <stdlib.h>
#include<bits/stdc++.h>
#define MAX_R  1000000
using namespace std;
static int R, L;
static long long B;
static int X[MAX_R];
static int solution;
int pr[N],ans=-1e18;
inline 
void my_assert(int e) {if (!e) abort();}
int solve(int l){
	int l1=l,r1=R;
	while(l1<r1){
		int mid=(l1+r1+1)/2,k=(l+mid)/2;
		if(X[k-1]*(k-l+1)-(pr[k]-pr[l-1])+(pr[mid]-pr[k])-(mid-k)*X[k-1]>B)r1=mid-1;
		else l1=mid;
	}
	return l1-l+1;
}
int besthub(int R,int L,int X[],int B){
	for(int i=0;i<R;i++)pr[i+1]+=pr[i]+X[i];
	for(int i=1;i<=R;i++)ans=max(solve(i),ans);
	return ans;
}
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;
}

Compilation message (stderr)

ricehub.cpp:11:8: error: 'N' was not declared in this scope
   11 | int pr[N],ans=-1e18;
      |        ^
ricehub.cpp:11:15: warning: overflow in conversion from 'double' to 'int' changes value from '-1.0e+18' to '-2147483648' [-Woverflow]
   11 | int pr[N],ans=-1e18;
      |               ^~~~~
ricehub.cpp: In function 'int solve(int)':
ricehub.cpp:18:36: error: 'pr' was not declared in this scope
   18 |                 if(X[k-1]*(k-l+1)-(pr[k]-pr[l-1])+(pr[mid]-pr[k])-(mid-k)*X[k-1]>B)r1=mid-1;
      |                                    ^~
ricehub.cpp: In function 'int besthub(int, int, int*, int)':
ricehub.cpp:24:29: error: 'pr' was not declared in this scope
   24 |         for(int i=0;i<R;i++)pr[i+1]+=pr[i]+X[i];
      |                             ^~