[Codeforces Round #152 (Div. 2)]A. Cupboards

地址:http://codeforces.com/contest/248/problem/A

开关壁橱的左右门使左右各自的闭合情况一样,输出最少动作次数

统计左,右的各自的和,过半则用n减

 1 #include<stdio.h>
 2 
 3 int n;
 4 
 5 int main()
 6 {
 7     int i,a,b,l=0,r=0;
 8     scanf("%d",&n);
 9     for(i=0;i<n;i++)
10     {
11         scanf("%d %d",&a,&b);
12         l+=a;
13         r+=b;
14     }
15     if(l>n/2) l=n-l;
16     if(r>n/2) r=n-r;
17     printf("%d\n",l+r);
18     return 0;
19 }

 

posted @ 2013-01-18 22:23  tjsuhst  阅读(155)  评论(0)    收藏  举报