Submission #655201

# Submission time Handle Problem Language Result Execution time Memory
655201 2022-11-03T14:23:18 Z Trumling Rice Hub (IOI11_ricehub) C++17
Compilation error
0 ms 0 KB
#include "ricehub.h"
#include<iostream>
#include<cmath>
using namespace std;

typedef long long ll;
#define pb push_back
#define F first
#define S second
#define enter cout<<'\n';

int besthub(int R, int L, int X[], long long B)
{
  bool arr[L+1]={ };
for(int i=0;i<R;i++)
{
    arr[X[i]]=true;
}
ll ans=1;
ll count=0;
ll plus=R;
while(plus!=1)
{
if(ans!=1)
break;

for(int i=0;i<=R-plus;i++)
{
ll med=(i+i+plus)/2;
ll curr=0;
for(int j=i;j<i+plus;j++)
    curr+=abs(X[med]-X[j]);
if(curr<=B)
{
    ans=plus;
    break;
}
}
plus--;
}
//cout<<'\n'<<ans<<'\n';
return ans;
}

#include "ricehub.h"
#include <stdio.h>
#include <stdlib.h>

#define MAX_R  1000000

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()
{
  ll anse;
  read_input();
  anse = besthub(R,L,X,B);
  if(anse==solution)
    printf("Correct.\n");
  else
    printf("Incorrect.  Returned %d instead of %d.\n",anse,solution);

  return 0;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:20:4: warning: unused variable 'count' [-Wunused-variable]
   20 | ll count=0;
      |    ^~~~~
ricehub.cpp: In function 'int main()':
ricehub.cpp:76:35: warning: format '%d' expects argument of type 'int', but argument 2 has type 'll' {aka 'long long int'} [-Wformat=]
   76 |     printf("Incorrect.  Returned %d instead of %d.\n",anse,solution);
      |                                  ~^                   ~~~~
      |                                   |                   |
      |                                   int                 ll {aka long long int}
      |                                  %lld
/usr/bin/ld: /tmp/ccllxiGX.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccrJEVNZ.o:ricehub.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status