Vases and Flowers
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 1336 Accepted Submission(s): 532
Problem Description
Alice is so popular that she can receive many flowers everyday. She has N vases numbered from 0 to N-1. When she receive some flowers, she will try to put them in the vases, one flower in one vase. She randomly choose the vase A and try to put a flower in the vase. If the there is no flower in the vase, she will put a flower in it, otherwise she skip this vase. And then she will try put in the vase A+1, A+2, ..., N-1, until there is no flower left or she has tried the vase N-1. The left flowers will be discarded. Of course, sometimes she will clean the vases. Because there are too many vases, she randomly choose to clean the vases numbered from A to B(A <= B). The flowers in the cleaned vases will be discarded.

本文介绍了一道名为Vases and Flowers的题目,涉及到数据结构的应用。题目要求处理花瓶中花的放置和清除操作,通过1操作在指定位置放置花朵,2操作清除指定区间内的花朵。解决方案采用简单线段树来维护区间和,1操作使用二分查找确定起始位置,2操作则统计区间内花朵数量。

550

被折叠的 条评论
为什么被折叠?



