#abc272g. G - Yet Another mod M
G - Yet Another mod M
Score : points
问题描述
给定一个由正整数组成的长度为 的序列 ,其中 中的元素各不相同。
你需要在 到 (包含)之间选择一个正整数 来执行以下操作一次:
- 对于满足 的每个整数 ,将 替换为 。
能否选择一个 ,使得操作后 满足以下条件?如果可以,请找出这样的 。
- 存在一个整数 ,它在 中是多数。
这里,若整数 在 中满足其等于 的整数个数大于不等于 的整数个数,则称 是 中的多数。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You are given a sequence of length consisting of positive integers, where the elements of are distinct.
You will choose a positive integer between and (inclusive) to perform the following operation once:
- For each integer such that , replace with .
Can you choose an so that satisfies the following condition after the operation? If you can, find such an .
- There exists an integer such that is the majority in .
Here, an integer is said to be the majority in if the number of integers such that is greater than the number of integers such that .
Constraints
- The elements of are distinct.
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
If there exists an that satisfies the condition, print such an . Otherwise, print .
Sample Input 1
5
3 17 8 14 10
Sample Output 1
7
If you let to perform the operation, you will have , where is the majority in , so satisfies the condition.
Sample Input 2
10
822848257 553915718 220834133 692082894 567771297 176423255 25919724 849988238 85134228 235637759
Sample Output 2
37
Sample Input 3
10
1 2 3 4 5 6 7 8 9 10
Sample Output 3
-1
update @ 2024/3/10 11:28:48