Gym - 101177J Just Terraffic!
Posted yy666
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Gym - 101177J Just Terraffic!相关的知识,希望对你有一定的参考价值。
Time limit: 3 seconds
The local council is recording traffic flow using a pressure pad laid across the road. The pressure pad tracks whenever the wheels on an axle of a vehicle cross the pressure pad. The only vehicles using the road are cars with two axles. Each vehicle may or may not have a single-axle trailer attached to it. When a car crosses the pressure pad, two times are recorded: one when the front wheels cross and another when the rear wheels cross. If the car is towing a trailer an additional time is recorded when the trailer wheels cross. Given a sequence of times from the recorder, the council wishes to know how many cars without trailers crossed the pad and how many cars with trailers crossed it.
Obviously, there is some ambiguity. For example, a sequence of 6 recordings could be three cars without trailers or two cars with trailers. To reduce such ambiguity, we will make the following two assumptions:
- Any two successive times with a difference less than or equal to 1000 ms must belong to the same vehicle.
- Any two successive times with a difference greater than or equal to 2000 ms must be from different vehicles.
Given a sequence of times, determine the number of cars with and without a trailer.
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 300 000), which is the number of times the pressure pad was triggered. The second line contains n distinct integers t1, . . . , tn (0 ≤ ti < $ 2^{30} $) in increasing order, the times that the pressure pad was triggered. The times are in milliseconds.
Output
Display the number of cars with and without trailers. If the number of cars of each type can be uniquely determined, then display two lines of the form
Cars without trailers: X
Cars with trailers: Y
If there is no interpretation of the times that is consistent with the assumptions, then display Impossible
. If there are multiple interpretations of the times that give different numbers of cars with and without trailers, then display Ambiguous
.
Sample Input 1
7
10 200 5000 6100 7200 8300 9400
Sample Output 1
Cars without trailers: 2
Cars with trailers: 1
Sample Input 2
6
0 1100 2200 3300 4400 5500
Sample Output 2
Ambiguous
Sample Input 3
4
0 1000 2000 3001
Sample Output 3
Impossible
以上是关于Gym - 101177J Just Terraffic!的主要内容,如果未能解决你的问题,请参考以下文章
gym101532 2017 JUST Programming Contest 4.0
cf gym 101177 J.Just Terraffic!
Gym - 100623J Just Too Lucky (数位dp)
CodeForces Gym 100685J Just Another Disney Problem (STL,排序)
困惑(fmap length Just)[1,1,1,1] vs. fmap length $ Just [1,1,1,1]