CF756B.Travel Card
普及/提高-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
A new innovative ticketing systems for public transport is introduced in Bytesburg. Now there is a single travel card for all transport. To make a trip a passenger scan his card and then he is charged according to the fare.
The fare is constructed in the following manner. There are three types of tickets:
- a ticket for one trip costs 20 byteland rubles,
- a ticket for 90 minutes costs 50 byteland rubles,
- a ticket for one day (1440 minutes) costs 120 byteland rubles.
Note that a ticket for x minutes activated at time t can be used for trips started in time range from t to t + x - 1, inclusive. Assume that all trips take exactly one minute.
To simplify the choice for the passenger, the system automatically chooses the optimal tickets. After each trip starts, the system analyses all the previous trips and the current trip and chooses a set of tickets for these trips with a minimum total cost. Let the minimum total cost of tickets to cover all trips from the first to the current is a, and the total sum charged before is b. Then the system charges the passenger the sum a - b.
You have to write a program that, for given trips made by a passenger, calculates the sum the passenger is charged after each trip.
字节堡推出了一种全新的创新型公共交通票务系统。现在,所有公共交通均使用统一的交通卡。乘客乘车时只需刷卡,系统即按票价扣费。
票价结构如下:共有三种车票:
- 单程票:每张 20 字节兰卢布;
- 90 分钟票:每张 50 字节兰卢布;
- 一日票(1440 分钟):每张 120 字节兰卢布。
注意:一张有效期为 x 分钟的车票,若在时刻 t 激活,则可在时间区间 [t,t+x−1](含端点)内用于乘坐任意行程。假设所有行程耗时恰好为 1 分钟。
为简化乘客选择,系统会自动选取最优的车票组合。每次行程开始后,系统将分析此前所有行程以及本次行程,并为这些行程选取总费用最小的一组车票。设覆盖从第一次行程到当前行程所需的车票最小总费用为 a,而此前已累计扣费总额为 b,则系统本次向乘客收取的金额为 a−b。
你需要编写一个程序,对给定的乘客行程序列,计算每次行程结束后乘客被收取的金额。
输入格式
The first line of input contains integer number n (1 ≤ n ≤ 105) — the number of trips made by passenger.
Each of the following n lines contains the time of trip t__i (0 ≤ t__i ≤ 109), measured in minutes from the time of starting the system. All t__i are different, given in ascending order, i. e. t__i + 1 > t__i holds for all 1 ≤ i < n.
输入的第一行包含一个整数 $ n ( 1 \leq n \leq 10^5 $)——表示乘客完成的行程次数。
接下来的 $ n $ 行中,每行包含一次行程的时间 $ t_i ( 0 \leq t_i \leq 10^9 $),单位为分钟,从系统启动时刻开始计时。所有 $ t_i $ 均互不相同,且按升序给出,即对所有 $ 1 \leq i < n $,均有 $ t_{i+1} > t_i $。
输出格式
Output n integers. For each trip, print the sum the passenger is charged after it.
输出 n 个整数。对于每次行程,输出乘客在该行程后被收取的费用总和。
输入输出样例
输入#1
3 10 20 30
输出#1
20 20 10
输入#2
10 13 45 46 60 103 115 126 150 256 516
输出#2
20 20 10 0 20 0 0 20 20 10
说明/提示
In the first example, the system works as follows: for the first and second trips it is cheaper to pay for two one-trip tickets, so each time 20 rubles is charged, after the third trip the system understands that it would be cheaper to buy a ticket for 90 minutes. This ticket costs 50 rubles, and the passenger had already paid 40 rubles, so it is necessary to charge 10 rubles only.
在第一个示例中,系统的工作方式如下:对于第一趟和第二趟行程,购买两张单程票更便宜,因此每次收费 20 卢布;第三趟行程时,系统判断购买一张有效期为 90 分钟的车票更为划算。该车票售价为 50 卢布,而乘客此前已支付了 40 卢布,因此只需再额外收取 10 卢布。
输入解题思路,AI测评打分。不知道怎么写?