QOJ.ac

QOJ

حد الوقت: 1 s حد الذاكرة: 1024 MB مجموع النقاط: 100

#3256. 数字速度计

الإحصائيات

数字速度计以每小时英里为单位显示车辆速度。在某些情况下,感应速度会在两个整数值之间波动,例如在使用巡航控制时。使用单一阈值在相邻整数之间进行舍入,往往会导致显示数值在两个整数之间快速切换,这会分散驾驶员的注意力。

您的团队必须实现一种平滑技术,通过使用单独的上升阈值($t_r$)和下降阈值($t_f$)来处理显示。请参阅图 1,了解根据以下规则使用样例输入时的图形描述。

每个感应速度 $s$ 都落在两个相邻整数 $i$ 和 $j$ 之间,即 $i \le s < j$,其中 $j = i + 1$。当将感应速度 $s$ 显示为整数时:

  • 当 $s$ 落在 $i$ 和 $i + t_f$ 之间时,$s$ 显示为 $i$。
  • 当 $s$ 落在 $i + t_r$ 和 $j$ 之间时,$s$ 显示为 $j$。
  • 当 $s$ 落在 $i + t_f$ 和 $i + t_r$ 之间时,如果最近一次落在区间 $[i + t_f, i + t_r]$ 之外的 $s$ 值小于 $i + t_r$,则 $s$ 显示为 $i$;如果最近一次落在区间 $[i + t_f, i + t_r]$ 之外的 $s$ 值大于 $i + t_r$,则 $s$ 显示为 $j$。
  • 任何感应速度 $0 < s < 1$ 都必须显示为 $1$,因为任何非零速度(无论多小)都必须显示为非零值,以表明车辆处于运动状态。

输入格式

输入的第一行包含下降阈值 $t_f$。第二行包含上升阈值 $t_r$。速度传感器以 $0.1$ mph 的增量报告速度 $s$。阈值始终设置在速度增量的中间。其余所有行直到文件结束均为连续的十进制速度 $s$(单位为每小时英里),每行一个速度。输入的第三行(即第一个测量速度)始终为 $0$。

$0 < t_f, t_r < 1; \quad t_f < t_r; \quad 0 \le s \le 120$

输出格式

输出为速度列表,每行一个速度,平滑处理为适合 $t_f$ 和 $t_r$ 的整数值。

图 1. 样例输入的传感器读数,其中 $t_f = 0.25$ 且 $t_r = 0.75$。

样例

输入 1

0.25
0.75
0
2.0
5.7
5.8
5.7
5.2
5.7
0.8
0.2

输出 1

0
2
5
6
6
5
5
1
1

说明

输入 输出 说明
0.25 $t_f$ 的值。
0.75 $t_r$ 的值。
0 0 初始输入。
2.0 2 输入大于 0,在阈值范围之外。
5.7 5 输入大于 2.0,在阈值范围内。
5.8 6 输入大于 2.0,超过上限阈值 5.75。
5.7 6 输入小于 5.8,在阈值范围内。
5.2 5 输入小于 5.8,低于阈值范围 5.25。
5.7 5 输入大于 5.2,在阈值范围内。
0.8 1 输入大于 0 且小于 1。
0.2 1 输入大于 0 且小于 1。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.