답안 #655197

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
655197 2022-11-03T14:20:17 Z Trumling 쌀 창고 (IOI11_ricehub) C++14
컴파일 오류
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()
{
  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: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:20:4: warning: unused variable 'count' [-Wunused-variable]
   20 | ll count=0;
      |    ^~~~~
/usr/bin/ld: /tmp/ccK8Yfsp.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cclBqnVq.o:ricehub.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status