답안 #133014

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
133014 2019-07-20T05:03:30 Z tinjyu 쌀 창고 (IOI11_ricehub) C++14
17 / 100
18 ms 1500 KB
#include "ricehub.h"
#include <iostream>
using namespace std;
long long int sum[100005],a[100005][2];
int besthub(int R, int L, int X[], long long B)
{
	int now=0;
	for(int i=0;i<R;i++)
	{
		sum[i]=sum[i-1]+X[i];
	}
	int s=1,e=1;
	int ans=0;
	while(s<=e && e<R)
	{
		//cout<<s<<" "<<e<<endl;
		long long int mid=(s+e)/2;
		//cout<<mid<<endl;
		long long int tmp=(X[mid]*(mid-s+1)-(sum[mid]-sum[s-1])+(sum[e]-sum[mid-1])-X[mid]*(e-mid+1));
		//cout<<tmp<<endl;
		if(tmp<=B)
		{
			ans=max(ans,e-s+1);
			e++;
		}
		else s++;
	}
  return ans;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:7:6: warning: unused variable 'now' [-Wunused-variable]
  int now=0;
      ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 2 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Incorrect 2 ms 380 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 632 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
3 Incorrect 18 ms 1500 KB Output isn't correct
4 Halted 0 ms 0 KB -