QOJ.ac

QOJ

時間限制: 1.0 s 記憶體限制: 256 MB 總分: 100 可 Hack ✓

#18182. Six Seven

统计

对于一个长度为 $n$ 的数组 $a$,我们定义该数组的 aura 为满足以下条件中至少一个的下标 $i$ ($1 \le i \le n - 1$) 的数量:

  • $a_i = 6$ 且 $a_{i+1} = 7$
  • $a_i = 7$ 且 $a_{i+1} = 6$

给你一个长度为 $n$ 的数组 $a$。你可以进行以下操作任意次:

  • 选择一个下标 $i$ ($1 \le i \le n - 1$) 并交换数组 $a$ 中的元素 $a_i$ 和 $a_{i+1}$。

在进行任意次(可能为零次)操作后,你想知道所得数组 $a$ 的最大可能 aura。

输入格式

第一行输入包含一个整数 $n$ ($2 \le n \le 100$)。

第二行输入包含 $n$ 个整数 $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 100$)。

输出格式

输出一个整数——在进行任意次操作后,数组 $a$ 的最大可能 aura。

样例

输入 1

4
1 2 3 4

输出 1

0

输入 2

7
2 6 1 7 3 5 4

输出 2

1

输入 3

5
6 6 7 7 7

输出 3

4

说明

在第一个样例中,无论进行多少次操作,都无法得到大于 $0$ 的 aura。

在第二个样例中,可以交换元素 $1$ 和 $6$ 得到 $[2, 1, 6, 7, 3, 5, 4]$,其 aura 为 $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.