A1099 | [COCI-2006_2007-regional]#3 FIREFLY
来源COCI
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
A Japanese firefly has flown into a cave full of obstacles: stalagmites (rising from the floor) and stalactites (hanging from the ceiling). The cave is N units long (where N is even) and H units high. The first obstacle is a stalagmite after which stalactites and stalagmites alternate.
Here is an example cave 14 units long and 5 units high (the image corresponds to the second example):
The Japanese firefly is not the type that would fly around the obstacle, instead it will choose a single height and ram from one end of the cave to the other destroying all obstacles in its path with its mighty kung-fu moves.
In the previous example, choosing the 4th level from the ground has the firefly destroying eight obstacles:
This is not the best choice because the firefly will end up less tired if it chooses either level one or five, as that would require destroying only seven obstacles.
You are given the width and length of the cave and the sizes of all obstacles.
Write a program that determines the minimum number of obstacles the firefly needs to destroy to reach the end of the cave, and on how many distinct levels it can achieve that number.
Here is an example cave 14 units long and 5 units high (the image corresponds to the second example):
The Japanese firefly is not the type that would fly around the obstacle, instead it will choose a single height and ram from one end of the cave to the other destroying all obstacles in its path with its mighty kung-fu moves.
In the previous example, choosing the 4th level from the ground has the firefly destroying eight obstacles:
This is not the best choice because the firefly will end up less tired if it chooses either level one or five, as that would require destroying only seven obstacles.
You are given the width and length of the cave and the sizes of all obstacles.
Write a program that determines the minimum number of obstacles the firefly needs to destroy to reach the end of the cave, and on how many distinct levels it can achieve that number.
输入格式
The first line contains two integers N and H, 2 ≤ N ≤ 200000, 2 ≤ H ≤ 500000, the length and height of the cave. N will always be even.
The next N lines contain the sizes of the obstacles, one per line. All sizes are positive integers less than H.
The next N lines contain the sizes of the obstacles, one per line. All sizes are positive integers less than H.
输出格式
Output two integers separated by a single space on a single line. The first number is the minimum number of obstacles the firefly has to destroy and the second is the number of levels on which that can be achieved.
输入输出样例
输入 #1
6 7 1 5 3 3 5 1
输出 #1
2 3
输入 #2
14 5 1 3 4 2 2 4 3 4 3 3 3 2 3 3
输出 #2
7 2
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted