cswork / OA打开练习工作台

ReevoOA #3

Exit Time with Elastic Collisions

估计中等评测数据准备中,可先阅读题面

考点(AI 标注)位运算原地数组

Objects are moving along a table of length tableLength. The position of the i-th object is given by position[i], when 0 <= position[i] < tableLength. The left end of the line is at coordinate 0, and the right end is at coordinate tableLength. A positive velocity means moving towards the right end, and a negative velocity means moving towards the left end.

When two objects collide, their velocities are exchanged. Objects are removed if they move left of coordinate 0 or right of coordinate tableLength. All objects keep moving simultaneously at time 0.

Your task is to find the time in seconds when the last object exits the line. The answer should be rounded to the nearest integer (ceiling).