#P7602. [THUPC 2021] 视频倍增期
[THUPC 2021] 视频倍增期
Description
To better measure video quality, Kuaishou’s product manager proposed the concept of a video “doubling period”. The doubling period is a time metric measured in seconds. It means the time it takes for a video’s cumulative views to increase from only half of the current value to the current total views. Low-quality videos often start strong but fade quickly: right after release, people click out of curiosity or because the title is attractive, but after some time the reputation drops sharply, so the doubling period is long. High-quality videos often start slow but grow later: after watching, people share and recommend it on their own, gradually building reputation and traffic, so the doubling period is shorter.
Xiaozhang is a backend administrator at Kuaishou. There are videos monitored by Xiaozhang, numbered from to . Xiaozhang has seconds of work time in a week. Each second, there is one request from the frontend to be processed. Requests are of two types:
- Update request: during this second, all videos with indices in the interval gain views, and the backend data needs to be updated.
- Query request: the frontend wants to know the doubling period of video . Suppose the current cumulative views of this video in this week is , and this query is sent at second . Let be the second when the cumulative views of this video in this week first reaches (with ). Then the doubling period is defined as .
Faced with such frequent updates and queries, Xiaozhang finds it difficult and hopes for your help.
Input Format
The first line contains two positive integers and , with .
The next lines describe the requests. Line represents the request at second (), and is in one of the following formats:
- : this is an update request. At second , videos with indices in () each gain views. It is guaranteed that .
- : this is a query request. Query the doubling period of video () at second .
Output Format
For each query request, output one line in order, giving the requested doubling period.
5 5
0 2 3 3
1 4
0 2 4 3
1 4
1 3
2
1
4
Hint
Sample Explanation
- At second , the cumulative views of video is . It reached the cumulative views at second , so its doubling period at this time is seconds.
- At second , the cumulative views of video is . It reached the cumulative views at second , so its doubling period at this time is second.
- At second , the cumulative views of video is . It reached the cumulative views at second , so its doubling period at this time is seconds.
Source
From the 2021 Tsinghua University Programming Contest and Collegiate Invitational (THUPC2021).
Resources such as editorial(s) can be found at https://github.com/yylidiw/thupc_0/tree/master.
Translated by ChatGPT 5
京公网安备 11011102002149号