답안 #563316

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
563316 2022-05-16T21:03:04 Z 1ne 쌀 창고 (IOI11_ricehub) C++14
0 / 100
572 ms 696 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;
  vector<int64_t>pref(R + 1,0),dpref(R + 1,0);
  for (int i = 0 ;i<R - 1;++i){
	  pref[i + 1] = pref[i] + (X[i + 1] - X[i]);
	  dpref[i + 2] = pref[i + 1] + dpref[i + 1];
  }
  auto dist = [&](int l,int r){
	 return pref[r] * (r - l) - dpref[r] + dpref[l];
  };
  for (int i = 0;i<R;++i){
		int l = 0;
		int left = 0,right = i;
		while(left<=right){
			int mid = (left + right)>>1;
			if (dist(mid,i)<=B){
				l = mid;
				right = mid - 1;
			} 
			else left = mid + 1;
		}
		int counts = i - l + 1;
		int j = i + 1;
		ans = max(ans,counts);
		while(j<R){
			if (dist(l,j)<=B){
				counts++;
				++j;
			}
			else{
				counts--;
				++l;
			}
			ans = max(ans,counts);
		}
  }
  return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 572 ms 696 KB Output isn't correct
2 Halted 0 ms 0 KB -