답안 #436959

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
436959 2021-06-25T11:39:48 Z adamjinwei 쌀 창고 (IOI11_ricehub) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "ricehub.h"
#define inf 1000000007
#define mod 1000000007
#define rnd() dist(rand_num)
//#pragma GCC optimize("Ofast","inline","-ffast-math")
//#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#define int long long
using namespace std;
unsigned seed=std::chrono::system_clock::now().time_since_epoch().count();
mt19937 rand_num(seed);
uniform_int_distribution<int> dist(0,inf);
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
template <typename T> void write(T x) {
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int n,m,b;
int x[100005];
bool check(int mid)
{
	if(mid==1) return b>=0;
	for(int l=1;l+mid-1<=n;++l)
	{
		int r=l+mid-1;
		if(mid%2==0)
		{
			int x1=(r+l-1)/2,x2=(r+l+1)/2;
			if(x[r]-x[x2-1]-x[x1]+x[l-1]<=b) return true;
		}
		else
		{
			int x1=(l+r)/2-1,x2=(l+r)/2+1;
			if(x[r]-x[x2-1]-x[x1]+x[l-1]<=b) return true;
		}
	}
	return false;
}
int besthub(int R,int L,int X[],int B)
{
	n=R;
	m=L;
	b=B;
	for(int i=1;i<=n;++i)
	{
		x[i]=X[i-1];
		x[i]+=x[i-1];
	}
	int l=1,r=n;
	while(l<r)
	{
		int mid=l+r+1>>1;
		if(check(mid)) l=mid;
		else
			r=mid-1;
	}
	return l;
}

Compilation message

ricehub.cpp: In function 'long long int besthub(long long int, long long int, long long int*, long long int)':
ricehub.cpp:62:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   62 |   int mid=l+r+1>>1;
      |           ~~~^~
/usr/bin/ld: /tmp/cctYfqmO.o: in function `main':
grader.cpp:(.text.startup+0xae): undefined reference to `besthub(int, int, int*, long long)'
collect2: error: ld returned 1 exit status