ztx

[Cqoi2010]扑克牌

ztx posted @ 2015年1月13日 19:29 in 二分 with tags 二分 , 2665 阅读
/****************************************\
* Author : ztx
* Title  : [Cqoi2010]扑克牌
* ALG    : 二分
* CMT    :
* 首先二分答案,设组成的套数为M,
* 在判断是否成立时 , 枚举每一个c , 若ci<M , 则用joker补,
* 使用的joker必须要小于等于min(m,M)
* Time   :
\****************************************/
/****************************************\
* Author : ztx
* Title  : [Cqoi2010]扑克牌
* ALG    : 二分
* CMT    :
* 首先二分答案,设组成的套数为M,
* 在判断是否成立时 , 枚举每一个c , 若ci<M , 则用joker补,
* 使用的joker必须要小于等于min(m,M)
* Time   :
\****************************************/

#include <cstdio>

#define  maxn  55LL
#define  maxc  1000000000LL

int n , m , i ;
int c[maxn] ;
int cnt ;

inline bool Could(int M) {
	cnt = 0 ;
	for (i = 1 ; i <= n ; i ++ ) {
		if (c[i] < M) cnt += M-c[i] ;
		if (cnt > M || cnt > m) return false ;
	}
	return true ;
}

int L , R , M ;
inline int Bsearch() {
	L = 0 , R = maxc+1 ;
	while (R-L > 1) {
		/* [L , R) */
		M = L+(R-L)/2 ;
		if (Could(M)) L = M ;
		else R = M ;
	}
	return L ;
}

int main() {
//	#define READ
	#ifdef  READ
		freopen(".in" ,"r",stdin ) ;
		freopen(".out","w",stdout) ;
	#endif
	scanf("%d%d", &n , &m ) ;
	for (i = 1 ; i <= n ; i ++ ) scanf("%d", &c[i] ) ;
	printf("%d\n", Bsearch() ) ;
	#ifdef  READ
		fclose(stdin) ; fclose(stdout) ;
	#else
		getchar() ; getchar() ;
	#endif
	return 0 ;
}
  • 无匹配
Avatar_small
cleaning company in 说:
2019年9月18日 17:08

You may be not searching for regular or even deep cleansing services, however something much more specialized such as cleaning businesses for furnishings, carpet, swimming pool, or drinking water tank! Furnishings cleaning businesses usually cost 100 – a hundred and fifty AED for each item (couch, carpet, and so on. )#) The pool cleaning company charges approx . 200 – four hundred AED in line with the pool dimension and regular cleaning is needed.

Avatar_small
river bank marketing 说:
2019年11月15日 01:34

Probably the most important points in life will be healthy--not simply physically, but psychologically and emotionally too. Follow these types of steps to produce a well-balanced, wholesome life.

Avatar_small
thai citrus technolo 说:
2020年3月24日 21:17

Any development for Wireless systems owes the whole works to Eliza Faraday - for identifying the standard of electromagnetic induction, to Harry Maxwell - to your Maxwell's equations as well as Guglielmo Marconi - for transmitting a wireless signal about one and a half miles. The only real purpose for Wi-Fi systems is mobile communication, through which unfortunately information are usually transferred between several points that will be not joined by electronic conductors.

Avatar_small
handi sports 说:
2020年3月24日 21:18

Sporting events Betting Champion, John Morrison, then started to come up with his experiencing, combining together his fire for sporting events and phone numbers, in everything of pro gambling. John is certainly well desirable, from people around the world, for this gambling recommendation.

Avatar_small
mentholatum home 说:
2020年3月24日 21:18

Most people will define expensive majorly when considering price but there is always much more now to luxury than simply the money you dedicate. It is amazingly hard to help you define expensive homes during an exact option because this is often something constructed from several reasons.

Avatar_small
I sell pittsburgh ho 说:
2020年3月24日 21:19

When you're buying a residence that had been inspected then you might want your possess inspection done to remain protected simply because fully as is feasible. If anyone notifies you that should be fine to utilise the last home inspection report they are really wrong. You're not secure well in the slightest degree. When Habitation Homework does a residence inspection the lawsuit pursuer can get a powerful 18 4 weeks warranty in the fee in 12 several months.

Avatar_small
wanamassa reale stat 说:
2020年3月24日 21:19

So you desire to be an achievement real personal investor? Clearly, you want your setting goals in sections. In order to achieve greatest opportunity of achieving ones own goals you will be setting BRIGHT goals. At present, not that Webster specific description of bright, but preferably SMART being a acronym designed for Specific, Measurable, A real possibility, Realistic, and even Timely.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter