洛谷 P2894 [USACO08FEB]Hotel G

这篇博客介绍了USACO08FEB竞赛中的题目Hotel G,涉及到的问题是在酒店房间分配中使用线段树来处理入住和退房请求。文章详细阐述了线段树的数据结构维护,包括节点信息、区间最大连续空房间的维护以及lazy标记的上下推更新策略。最后给出了AC代码实现。
摘要由CSDN通过智能技术生成

题目描述:

The cows are journeying north to Thunder Bay in Canada to gain cultural enrichment and enjoy a vacation on the sunny shores of Lake Superior. Bessie, ever the competent travel agent, has named the Bullmoose Hotel on famed Cumberland Street as their vacation residence. This immense hotel has N ( 1 ≤ N ≤ 50 , 000 ) N (1 \leq N \leq 50,000) N(1N50,000) rooms all located on the same side of an extremely long hallway (all the better to see the lake, of course).

The cows and other visitors arrive in groups of size D i ( 1 ≤ D i ≤ N ) Di (1 \leq D_i \leq N) Di(1DiN) and approach the front desk to check in. Each group i requests a set of Di contiguous rooms from Canmuu, the moose staffing the counter. He assigns them some set of consecutive room numbers r . . . r + D i − 1 r...r+D_i-1 r...r+Di1 if they are available or, if no contiguous set of rooms is available, politely suggests alternate lodging. Canmuu always chooses the value of r to be the smallest possible.

Visitors also depart the hotel from groups of contiguous rooms. Checkout i has the parameters X i X_i Xi and D i D_i Di which specify the vacating of rooms X i . . . X i + D i − 1 ( 1 ≤ X i ≤ N − D i + 1 ) X_i ...X_i +D_i-1 (1 \leq X_i \leq N-D_i+1) Xi...Xi+Di1(1XiNDi+1). Some (or all) of those rooms might be empty before the checkout.

Your job is to assist Canmuu by processing M ( 1 ≤ M ≤ 50 , 000 ) M (1 \leq M \leq 50,000) M(1M50,000) checkin/checkout requests. The hotel is initially unoccupied.

参考样例,第一行输入 n n n m m

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值