A1188 | [COCI-2010_2011-contest1]#2 PROFESOR
来源COCI
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
In a long classroom, N desks are arranged in a single row, with two students sitting at each desk.
Students are cranky because they are about to have an art class, and their professor is planning to examine them.
Each student has studied art, but only to a certain level. The old professor can tell by the looks on their faces just how much they have studied. The professor, being an artist, uses a different coloured pencil for each grade. Unfortunately, today he brought only one pencil.
In order to make the examination seem fair, he wants to choose two desks and question one student from each desk positioned between the two desks he has chosen (including the chosen desks). It is important that all examined students deserve the same grades, so he can write them down using his only pencil.
The professor wants to know the maximum number of students he can examine this way, as well as which grade the students will get.
Students are cranky because they are about to have an art class, and their professor is planning to examine them.
Each student has studied art, but only to a certain level. The old professor can tell by the looks on their faces just how much they have studied. The professor, being an artist, uses a different coloured pencil for each grade. Unfortunately, today he brought only one pencil.
In order to make the examination seem fair, he wants to choose two desks and question one student from each desk positioned between the two desks he has chosen (including the chosen desks). It is important that all examined students deserve the same grades, so he can write them down using his only pencil.
The professor wants to know the maximum number of students he can examine this way, as well as which grade the students will get.
输入格式
The first line of input contains a single integer N (1 ≤ N ≤ 100 000).
Each of the following N rows contains two integers: Ai and Bi , grades deserved by students sitting at desk i (1 ≤ Ai , Bi ≤ 5).
Each of the following N rows contains two integers: Ai and Bi , grades deserved by students sitting at desk i (1 ≤ Ai , Bi ≤ 5).
输出格式
The first and only line of output must contain two numbers separated by a single space: the maximum number of students the professor can examine and the grade those students will get.
If there are multiple solutions possible, output the one with the smallest grade.
If there are multiple solutions possible, output the one with the smallest grade.
输入输出样例
输入 #1
1 1 5
输出 #1
1 1
输入 #2
3 3 5 4 5 1 3
输出 #2
2 5
输入 #3
4 2 1 3 2 5 3 2 5
输出 #3
2 2
Test cases worth 70% of total points have N ≤ 100.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted