• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            superman

            聚精會神搞建設 一心一意謀發展
            posts - 190, comments - 17, trackbacks - 0, articles - 0
               :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

            Section 2.1 - Sorting A Three-Valued Sequence

            Posted on 2009-03-26 13:27 superman 閱讀(83) 評論(0)  編輯 收藏 引用 所屬分類: USACO
             1 #include <iostream>
             2 
             3 using namespace std;
             4 
             5 int main()
             6 {
             7     freopen("sort3.in""r", stdin);
             8     freopen("sort3.out""w", stdout);
             9 
            10     int n, x[1000];
            11     int c[10][10= { 0 };
            12     int t1 = 0, t2 = 0, t3 = 0;
            13 
            14     cin >> n;
            15     for (int i = 0; i < n; i++)
            16     {
            17         cin >> x[i];
            18         if (x[i] == 1) t1 += 1;
            19         if (x[i] == 2) t2 += 1;
            20         if (x[i] == 3) t3 += 1;
            21     }
            22 
            23     for (int i = 0; i < t1; i++)
            24     {
            25         if (x[i] == 2) c[1][2+= 1;
            26         if (x[i] == 3) c[1][3+= 1;
            27     }
            28     for (int i = t1; i < t1 + t2; i++)
            29     {
            30         if (x[i] == 1) c[2][1+= 1;
            31         if (x[i] == 3) c[2][3+= 1;
            32     }
            33     for (int i = t1 + t2; i < n; i++)
            34     {
            35         if (x[i] == 1) c[3][1+= 1;
            36         if (x[i] == 2) c[3][2+= 1;
            37     }
            38 
            39     int t, ans = 0;
            40 
            41     t = min(c[1][2], c[2][1]);
            42     c[1][2-= t, c[2][1-= t, ans += t;
            43     t = min(c[1][3], c[2][1]);
            44     c[1][3-= t, c[2][1-= t, c[2][3+= t, ans += t;
            45 
            46     t = min(c[1][3], c[3][1]);
            47     c[1][3-= t, c[3][1-= t, ans += t;
            48     t = min(c[1][2], c[3][1]);
            49     c[1][2-= t, c[3][1-= t, c[3][2+= t, ans += t;
            50 
            51     t = min(c[2][3], c[3][2]);
            52     c[2][3-= t, c[3][2-= t, ans += t;
            53 
            54     cout << ans << endl;
            55 
            56     return 0;
            57 }
            58 
            久久久噜噜噜www成人网| 99久久中文字幕| 久久91精品国产91| 囯产精品久久久久久久久蜜桃| 久久精品中文闷骚内射| 色综合久久中文综合网| 亚洲精品午夜国产va久久| 亚洲级αV无码毛片久久精品| 国产精品久久久久天天影视| 蜜桃麻豆www久久国产精品| 久久精品国产亚洲AV香蕉| 久久精品成人| 久久夜色撩人精品国产| 久久人人爽人人爽人人片av高请| 亚洲国产精品人久久| 狠狠色婷婷久久综合频道日韩| 久久综合九色综合欧美狠狠| 午夜精品久久久久久久久| 亚洲婷婷国产精品电影人久久| 久久免费精品一区二区| 久久久久久久久无码精品亚洲日韩| 欧美性大战久久久久久| 久久青青草原综合伊人| 久久99精品久久只有精品| 国产aⅴ激情无码久久| 久久婷婷是五月综合色狠狠| 国产综合精品久久亚洲| 久久香蕉国产线看观看99| 久久久久亚洲Av无码专| 一本一道久久综合狠狠老| 久久国语露脸国产精品电影| 99久久这里只精品国产免费| 日韩亚洲国产综合久久久| 久久这里只有精品视频99| 久久www免费人成看国产片| 草草久久久无码国产专区| 日本久久久久久中文字幕| 国产精品亚洲综合专区片高清久久久 | 久久影院亚洲一区| 日韩AV毛片精品久久久| 亚洲欧美一级久久精品|