301326: CF248A. Cupboards

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Cupboards

题意翻译

在一个很长的走廊上,左右两边的门的状态都是十分整齐的(在一边的门的状态相同),现在有一个人随意开关了一些门,使得这些门看起来十分乱。现在他想把这些门还原到整齐的状态中,请问他最少需要改变几扇门的状态才可以使得左右两边门的状态是整齐的(在一边的一扇门要 么都开要么都关) 第一行一个正整数n 后n行每行两个整数x,y(0<=x,y<=1)0表示关着,1表示开着,x表示左边门的状态,y表示右边门的状态 输出一个正整数表示最小改变次数

题目描述

One foggy Stockholm morning, Karlsson decided to snack on some jam in his friend Lillebror Svantenson's house. Fortunately for Karlsson, there wasn't anybody in his friend's house. Karlsson was not going to be hungry any longer, so he decided to get some food in the house. Karlsson's gaze immediately fell on $ n $ wooden cupboards, standing in the kitchen. He immediately realized that these cupboards have hidden jam stocks. Karlsson began to fly greedily around the kitchen, opening and closing the cupboards' doors, grab and empty all the jars of jam that he could find. And now all jars of jam are empty, Karlsson has had enough and does not want to leave traces of his stay, so as not to let down his friend. Each of the cupboards has two doors: the left one and the right one. Karlsson remembers that when he rushed to the kitchen, all the cupboards' left doors were in the same position (open or closed), similarly, all the cupboards' right doors were in the same position (open or closed). Karlsson wants the doors to meet this condition as well by the time the family returns. Karlsson does not remember the position of all the left doors, also, he cannot remember the position of all the right doors. Therefore, it does not matter to him in what position will be all left or right doors. It is important to leave all the left doors in the same position, and all the right doors in the same position. For example, all the left doors may be closed, and all the right ones may be open. Karlsson needs one second to open or close a door of a cupboard. He understands that he has very little time before the family returns, so he wants to know the minimum number of seconds $ t $ , in which he is able to bring all the cupboard doors in the required position. Your task is to write a program that will determine the required number of seconds $ t $ .

输入输出格式

输入格式


The first input line contains a single integer $ n $ — the number of cupboards in the kitchen ( $ 2<=n<=10^{4} $ ). Then follow $ n $ lines, each containing two integers $ l_{i} $ and $ r_{i} $ $ (0<=l_{i},r_{i}<=1) $ . Number $ l_{i} $ equals one, if the left door of the $ i $ -th cupboard is opened, otherwise number $ l_{i} $ equals zero. Similarly, number $ r_{i} $ equals one, if the right door of the $ i $ -th cupboard is opened, otherwise number $ r_{i} $ equals zero. The numbers in the lines are separated by single spaces.

输出格式


In the only output line print a single integer $ t $ — the minimum number of seconds Karlsson needs to change the doors of all cupboards to the position he needs.

输入输出样例

输入样例 #1

5
0 1
1 0
0 1
1 1
0 1

输出样例 #1

3

Input

题意翻译

在一个很长的走廊上,左右两边的门的状态都是十分整齐的(在一边的门的状态相同),现在有一个人随意开关了一些门,使得这些门看起来十分乱。现在他想把这些门还原到整齐的状态中,请问他最少需要改变几扇门的状态才可以使得左右两边门的状态是整齐的(在一边的一扇门要 么都开要么都关) 第一行一个正整数n 后n行每行两个整数x,y(0<=x,y<=1)0表示关着,1表示开着,x表示左边门的状态,y表示右边门的状态 输出一个正整数表示最小改变次数

加入题单

算法标签: