problem 1622

来源:互联网 发布:centos netsnmp 编辑:程序博客网 时间:2024/06/01 10:25
  1. //几百年没做题了,想不到这题还跑了个第一!
  2. //2008-09-19 17:02:34 C++ 0ms 256Kb
  3. #include<stdio.h>
  4. void solve(int n)
  5. {
  6.     int res1 = 0, res2 = 0;
  7.     for(int i = 0; i < n; i++)
  8.     {
  9.         int light;
  10.         scanf("%d", &light);
  11.         light == (i & 1) ? res1++ : res2++;
  12.     }
  13.     printf("%d/n", (res1 >= res2 ? res2 : res1));
  14. }
  15. int main()
  16. {
  17. #ifndef ONLINE_JUDGE
  18.     freopen("1622.txt""r", stdin);
  19. #endif
  20.     int n;
  21.     while(scanf("%d", &n) != EOF )
  22.         solve(n);
  23. #ifndef ONLINE_JUDGE
  24.     fclose(stdin);
  25. #endif
  26. }
原创粉丝点击