A1103 | [COCI-2007_2008-contest1]#3 PRINOVA
来源COCI
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
Brojko and Brojana are happily married with N little boys. The boys are named with distinct even integers P1, P2, ..., PN.
Brojko and Brojana are expecting an addition to their family and have to come up with a nice name for the little girl. They have decided that the name will be an odd integer in the range [A, B]. Because they find all integers in that range equally beautiful, they have decided to choose the number which maximizes the distance to the name of the closest of the N boys.
More precisely, they seek an odd integer X ∈[A,B] such that the expression min{X − Pi,i ∈[ ,1 N]}
is as large as possible.
Write a program that determines the name for the little girl. If there are multiple solutions, output any of them.
Brojko and Brojana are expecting an addition to their family and have to come up with a nice name for the little girl. They have decided that the name will be an odd integer in the range [A, B]. Because they find all integers in that range equally beautiful, they have decided to choose the number which maximizes the distance to the name of the closest of the N boys.
More precisely, they seek an odd integer X ∈[A,B] such that the expression min{X − Pi,i ∈[ ,1 N]}
is as large as possible.
Write a program that determines the name for the little girl. If there are multiple solutions, output any of them.
输入格式
The first line contains an integer N (1 ≤ N ≤ 100), the number of boys.
The second line contains N distinct even integers, the names of the boys. The integers will be less than 10^
9.
The third line contains the integers A and B (1 ≤ A < B ≤ 10^9), the range of names they are considering for the girl.
The second line contains N distinct even integers, the names of the boys. The integers will be less than 10^
9.
The third line contains the integers A and B (1 ≤ A < B ≤ 10^9), the range of names they are considering for the girl.
输出格式
Output an integer, the name for the little girl.
输入输出样例
输入 #1
3 2 6 16 20 50
输出 #1
49
输入 #2
3 2 6 16 3 15
输出 #2
11
输入 #3
3 2 6 16 1 7
输出 #3
5
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted