#B3768. Voyage of Memories
Voyage of Memories
Voyage of Memories
zyl is a junior high school OIer who left his hometown by boat at 2023-04-01 00:00:00 to chase his dream. His destination is located S m away from home. The boat initially sails at a constant speed of \(v_{0}\ m/s\). Along the way, he keeps thinking of the one he loves. Each time he starts thinking, he immediately reverses his boat towards home. He thinks a total of \(n\) times. The \(i\)-th thought starts after sailing for \(T_{i}\) seconds (measured at the constant speed \(v_{0}\)).
For the first thought event, he thinks for \(t_{1}\) seconds and sails homeward at speed \(v_{1}\ m/s\). For every subsequent thought event \(i\) (\(i \ge 2\)), his thinking duration increases by \(t_{2}\) seconds and his homeward speed increases by \(v_{2}\ m/s\); formally, for \(i\ge2\):
[ \begin{aligned} t_{i} &= t_{i-1} + t_{2},\ v_{i} &= v_{i-1} + v_{2}. \end{aligned} ]
Whenever a thought event is triggered, if zyl has already reached his destination, he does nothing further and just stands there. Otherwise, when a thought event begins, he immediately reverses course and sails homeward at the specified speed for the thought duration. If during this backward journey he reaches home (i.e. his position becomes 0) before the thought duration expires, he will wait at home for the remaining time of that thought to play chess with her. After the thought event ends, he reverses direction again, sails towards his destination at the original speed \(v_{0}\) and continues his journey. Once he reaches his destination, he stops.
Assume that all input values are such that zyl will arrive at his destination before 2023-04-30 23:59:59. Determine the exact date and time (in the format YYYY-MM-DD HH:MM:SS
) at which zyl reaches his destination.
inputFormat
The input consists of three parts:
- The first line contains three integers:
S
(the distance between his hometown and destination in meters),v0
(the boat's initial speed in m/s), andn
(the number of thought events), where \(1 \le n \le 100\). - The second line contains four integers:
t1
andv1
(the duration in seconds and speed in m/s of the first thought event), followed byt2
andv2
(the increments for duration and speed for each subsequent thought event). - The third line contains \(n\) integers: \(T_{1}, T_{2}, \ldots, T_{n}\), where the \(i\)-th integer indicates that the \(i\)-th thought event is triggered after sailing for \(T_{i}\) seconds (at speed \(v0\)).
All numbers are separated by spaces.
outputFormat
Output a single line containing the date and time at which zyl reaches his destination, in the format YYYY-MM-DD HH:MM:SS
.
sample
105 10 2
3 5 2 1
5 7
2023-04-01 00:00:15