답안 #120049

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
120049 2019-06-23T06:19:00 Z turbat 쌀 창고 (IOI11_ricehub) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;

long long s[100005];

long long can(int l, int r){
	int mid = (l + r) / 2;
	if ((r - l) % 2) return s[r] + s[l - 1] - 2 * s[mid];		
	return s[r] + s[l - 1] - s[mid] - s[mid - 1];
}

int besthub(int R, int L, int X[], long long B){
	int ans = 0;
	for (int i = 1;i <= R;i++) s[i] = s[i - 1] + X[i - 1];
	for (int i = 1;i <= R;i++){
		int l = i, r = R, mid;
		while (l != r){
			mid = (l + r + 1) / 2;
			if (can(l, mid) <= B) l = mid;
			else r = mid - 1;
		}
		ans = max(ans, l - i + 1);
	}
  return ans;
}
#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;

long long s[100005];

long long can(int l, int r){
	int mid = (l + r) / 2;
	if ((r - l) % 2) return s[r] + s[l - 1] - 2 * s[mid];		
	return s[r] + s[l - 1] - s[mid] - s[mid - 1];
}

int besthub(int R, int L, int X[], long long B){
	int ans = 0;
	for (int i = 1;i <= R;i++) s[i] = s[i - 1] + X[i - 1];
	for (int i = 1;i <= R;i++){
		int l = i, r = R, mid;
		while (l != r){
			mid = (l + r + 1) / 2;
			if (can(l, mid) <= B) l = mid;
			else r = mid - 1;
		}
		ans = max(ans, l - i + 1);
	}
  return ans;
}

Compilation message

ricehub.cpp:31:19: error: redefinition of 'long long int s [100005]'
 long long s[100005];
                   ^
ricehub.cpp:5:11: note: 'long long int s [100005]' previously declared here
 long long s[100005];
           ^
ricehub.cpp: In function 'long long int can(int, int)':
ricehub.cpp:33:11: error: redefinition of 'long long int can(int, int)'
 long long can(int l, int r){
           ^~~
ricehub.cpp:7:11: note: 'long long int can(int, int)' previously defined here
 long long can(int l, int r){
           ^~~
ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:39:5: error: redefinition of 'int besthub(int, int, int*, long long int)'
 int besthub(int R, int L, int X[], long long B){
     ^~~~~~~
ricehub.cpp:13:5: note: 'int besthub(int, int, int*, long long int)' previously defined here
 int besthub(int R, int L, int X[], long long B){
     ^~~~~~~