A1321 | [COCI-2015_2016-contest6]#4 PIANINO
来源COCI
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
Young Mirka is an amateur musician. She plays the multi-piano. A multi-piano consists of an infinite number of multi-keys, denoted with integers that can be interpreted as the pitch. A multi-composition (a composition written for a multi-piano) can be represented with a finite array of integers, where integers denote the order of multi-keys to press in order to play the multi-composition.
Young Mirka has heard a multi-composition on the multi-radio and now she wants to play it. Unfortunately, she cannot hear exactly which key was pressed, but instead she can hear whether the pressed multi-key was higher, lower or equal to the previously played key (a higher key is denoted with a larger number). Therefore she has decided to play the composition in the following way:
• before playing, she will choose one non-negative integer K
• in the beginning, she will play the correct multi-key (her multi-teacher told her which multi-key that is)
• when she hears that the multi-key played in the multi-composition is higher than the previous multi-key played in the multi-composition, she will play the multi-key denoted with the integer larger than the multi-key she played previously by K
• analogously, when she hears that the multi-key played in the multi-composition is lower than the previous multi-key played in the multi-composition, she will play the multi-key denoted with the integer smaller than the multi-key she played previously by K
• when she hears that the multi-key played in the multi-composition is equal to the previous multi-key played in the multi-composition, she will repeat the multi-key she played previously Notice that, when Mirka is playing, she does not compare the pitch of the keys she played to the pitch of the keys from the composition.
Help Mirka choose the integer K in order to hit as many correct pitches as possible.
Young Mirka has heard a multi-composition on the multi-radio and now she wants to play it. Unfortunately, she cannot hear exactly which key was pressed, but instead she can hear whether the pressed multi-key was higher, lower or equal to the previously played key (a higher key is denoted with a larger number). Therefore she has decided to play the composition in the following way:
• before playing, she will choose one non-negative integer K
• in the beginning, she will play the correct multi-key (her multi-teacher told her which multi-key that is)
• when she hears that the multi-key played in the multi-composition is higher than the previous multi-key played in the multi-composition, she will play the multi-key denoted with the integer larger than the multi-key she played previously by K
• analogously, when she hears that the multi-key played in the multi-composition is lower than the previous multi-key played in the multi-composition, she will play the multi-key denoted with the integer smaller than the multi-key she played previously by K
• when she hears that the multi-key played in the multi-composition is equal to the previous multi-key played in the multi-composition, she will repeat the multi-key she played previously Notice that, when Mirka is playing, she does not compare the pitch of the keys she played to the pitch of the keys from the composition.
Help Mirka choose the integer K in order to hit as many correct pitches as possible.
输入格式
The first line of input contains the integer N (2 6 N 6 106 ), the number of multi-keys in the multicomposition on the multi-radio.
The second line of input contains N integers ai (−109 6 ai 6 109 ), the multi-keys played in the multi-composition.
The second line of input contains N integers ai (−109 6 ai 6 109 ), the multi-keys played in the multi-composition.
输出格式
The first line of output must contain the maximum number of multi-keys that Mirka can play correctly.
The second line of output must contain the non-negative number K that Mirka must choose in order to hit as many correct pitches as possible. The number must be smaller than or equal to 2 · 109 .
Please note: The required number does not have to be unique, but will surely exist within the given constraints.
The second line of output must contain the non-negative number K that Mirka must choose in order to hit as many correct pitches as possible. The number must be smaller than or equal to 2 · 109 .
Please note: The required number does not have to be unique, but will surely exist within the given constraints.
输入输出样例
输入 #1
5 1 2 0 3 1
输出 #1
3 2
输入 #2
7 2 1 -6 -2 1 6 10
输出 #2
5 4
Clarification of the first example: Mirka will play the following keys, respectively: 1, 2, 0, 3, 1. Denoted
in bold are the keys that she played correctly.
Clarification of the second example: Mirka will play the following keys, respectively: 2, -2, -6, -2, 2, 6,
10.
in bold are the keys that she played correctly.
Clarification of the second example: Mirka will play the following keys, respectively: 2, -2, -6, -2, 2, 6,
10.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted