AT_abc484_b.Nineball
入门
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are playing nine-ball, a billiards game.
This game uses a total of 9 balls, one for each number from 1 to 9.
Currently, K balls remain on the table, and their numbers are A1,A2,…,AK.
It is now your turn, and you must aim at the lowest-numbered ball remaining on the table. However, if the ball numbered 9 is no longer on the table, the game has already ended.
Print the number of the ball you should aim at on your turn. However, if the ball numbered 9 is not on the table, the game has already ended, so print -1 instead.
你正在玩九球,一种台球游戏。
该游戏共使用 9 个球,编号分别为 1 至 9。
目前桌面上还剩下 K 个球,其编号为 A1,A2,…,AK。
现在轮到你击球,你必须瞄准桌面上剩余编号最小的球。但若编号为 9 的球已不在桌面上,则游戏已经结束。
请输出你本轮应瞄准的球的编号;但如果编号为 9 的球不在桌面上(即游戏已结束),则输出 -1。
输入格式
The input is given from Standard Input in the following format:
K
A1 A2 … AK
输入从标准输入中按以下格式给出:
K
A1 A2 … AK
输出格式
Print the answer.
输出答案。
输入输出样例
输入#1
5 6 4 2 9 8
输出#1
2
输入#2
4 8 2 4 6
输出#2
-1
输入#3
3 7 9 6
输出#3
6
说明/提示
Sample 1 Explanation:
The balls numbered 2,4,6,8,9 remain on the table, and the ball you should aim at next is the one numbered 2.
Sample 2 Explanation:
The balls numbered 2,4,6,8 remain on the table, but the ball numbered 9 does not.
In this case, the game has already ended, so the answer is -1.
Constraints
- All input values are integers.
- 1≤K≤9
- 1≤Ai≤9
- The values Ai are distinct.
样例 1 解释:
编号为 2,4,6,8,9 的球仍留在桌面上,接下来你应该瞄准编号为 2 的球。
样例 2 解释:
编号为 2,4,6,8 的球仍留在桌面上,但编号为 9 的球不在。
此时游戏已结束,因此答案为 -1。
约束条件
- 所有输入值均为整数。
- 1≤K≤9
- 1≤Ai≤9
- 各 Ai 的值互不相同。
输入解题思路,AI测评打分。不知道怎么写?