답안 #61012

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
61012 2018-07-25T05:59:44 Z nvmdava 쌀 창고 (IOI11_ricehub) C++17
17 / 100
1000 ms 972 KB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;


bool price(int X[], int l,int r, long long B){
	
	int i;
	long long p = 0;
	int m = (r + l) / 2;
	
	for(i = l; i <m ; i++){
		p +=(long long)(X[m] - X[i]);
	}
	
	for(i = m + 1; i <=r ; i++){
		p +=(long long)(X[i] - X[m]);
	}
	
	if(p <= B){
		return 1;
	} else {
		return 0;
	}
	
}

int besthub(int n, int L, int X[], long long B)
{
	int l = 0, r = 0, m,dif = -1,i;
	for(i = 0; i < n;i++){
		l = i; r = n - 1;
		while(l < r){
			m = (l+r) / 2;
			if(price(X,i,m,B)){
				l = m + 1;
			} else {
				r = m;
			}
		}
		dif = max(dif , r - i);
	}
	return dif;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 356 KB Output is correct
3 Correct 2 ms 392 KB Output is correct
4 Correct 3 ms 476 KB Output is correct
5 Correct 2 ms 496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 572 KB Output is correct
2 Correct 2 ms 572 KB Output is correct
3 Incorrect 2 ms 572 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 572 KB Output is correct
2 Correct 2 ms 572 KB Output is correct
3 Incorrect 6 ms 572 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 221 ms 688 KB Output is correct
2 Correct 237 ms 688 KB Output is correct
3 Execution timed out 1068 ms 972 KB Time limit exceeded
4 Halted 0 ms 0 KB -