답안 #563295

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
563295 2022-05-16T19:42:27 Z 1ne 쌀 창고 (IOI11_ricehub) C++14
컴파일 오류
0 ms 0 KB
//#include "ricehub.h"
#include<bits/stdc++.h>
using namespace std;
int besthub(int R, int L, int X[], long long B)
{
  int ans = 0;
  for (int i = 0;i<R;++i){
		int l = 0;
		long long cost = B;
		int left = 0,right = i;
		while(left<=right){
			int mid = (left + right)>>1;
			if (X[i] - X[mid]<=B){
				l = mid;
				right = mid - 1;
			} 
			else left = mid + 1;
		}
		ans = max(ans,i - l + 1);
  }
  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:9:13: warning: unused variable 'cost' [-Wunused-variable]
    9 |   long long cost = B;
      |             ^~~~
/usr/bin/ld: /tmp/ccw9Nlq3.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccUhOcE5.o:ricehub.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status