QOJ.ac

QOJ

时间限制: 4 s 内存限制: 1024 MB 总分: 100

#13885. 海克斯科技军械

统计

Heimerdinger 正在访问著名的西蒙斯研究所(Simons Institute),这是世界领先的计算理论研究机构——最近也开始研究海克斯科技(hextech)。他正在帮助研究人员检测海克斯军备(hextech ordnance)的奇异特性。一个海克斯军备样本给出了 $n$ 个读数 $a_1, a_2, \dots, a_n$。Heimerdinger 意识到,当且仅当对于所有 $1 \le k \le n$,都存在至少 $k$ 个长度至少为 2 的子数组,满足该子数组的最大值与最小值之差最多为 $k$ 时,该军备才是稳定的。形式化地,如果对于所有 $1 \le k \le n$,都存在至少 $k$ 个子数组 $[i, j]$ 满足以下条件,则该军备是稳定的:

  • $1 \le i < j \le n$,
  • $\max(a_i, a_{i+1}, \dots, a_j) - \min(a_i, a_{i+1}, \dots, a_j) \le k$。

Heimerdinger 自己不太清楚该如何检查这些读数,而且他已经给所有的学生分配了研究胡须丰盈剂这一至关重要的任务。因此,他向你——西蒙斯研究所的一位年轻新星研究员——寻求帮助。

输入格式

输入的第一行包含一个整数 $n$($1 \le n \le 10^6$),表示读数的数量。

第二行包含 $n$ 个空格分隔的整数 $a_1, a_2, \dots, a_n$($0 \le a_i \le 10^9$),表示来自海克斯核心(hexcore)的读数。

输出格式

如果军备是稳定的,输出 stable。否则,输出 unstable

样例

输入样例 1

10
10 3 8 2 6 5 3 4 4 10

输出样例 1

stable

输入样例 2

10
3 15 19 7 15 18 17 4 19 1

输出样例 2

unstable

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.