답안 #108173

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
108173 2019-04-27T20:30:36 Z SecretAgent007 쌀 창고 (IOI11_ricehub) C++17
0 / 100
21 ms 1536 KB
#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;

const long long INF = 1e18;

vector< long long > pref;

long long calc(int left, int right, long long B, int X[]){
	
	long long l = left, r = right;
	
	while(l < r){
		long long mid = (l+r+1)/2;
		
		long long k = (l+mid+1)/2;
		
		long long cost = X[k-1]*(k-left+1)-(pref[k]-pref[left-1])+(pref[mid]-pref[k])-(mid-k)*X[k-1];
		
		if(cost > B){
			r = mid-1;
		}else{
			l = mid;
		}
	}
	
	return l-left+1;
}

int besthub(int R, int L, int X[], long long B){

	pref.resize(R+1);
	
	for(int i = 0; i < R; i++){
		pref[i+1] += pref[i];
		pref[i+1] += X[i];
	}
	
	long long ans = -INF;
	
	for(int i = 1; i <= R; i++){
		ans = max(calc(i,R,B,X), ans);
	}
	
	return ans;
}
/*
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int r, l, b;
	cin >> r >> l >> b;
	
	int x[r];
	
	for(int i = 0; i < r; i++) cin >> x[i];
	
	cout << besthub(r,l,x,b) << endl;
}
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Incorrect 2 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Incorrect 2 ms 256 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Incorrect 2 ms 256 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 5 ms 640 KB Output is correct
3 Correct 21 ms 1528 KB Output is correct
4 Incorrect 21 ms 1536 KB Output isn't correct
5 Halted 0 ms 0 KB -