• <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 閱讀(78) 評論(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 
            亚洲乱亚洲乱淫久久| 久久久久亚洲AV无码观看| 久久精品国产亚洲精品| 久久99国产精品99久久| 久久久久亚洲AV无码专区网站| 久久高潮一级毛片免费| 亚洲欧洲日产国码无码久久99| 日本精品久久久久中文字幕8| 模特私拍国产精品久久| 91精品国产高清91久久久久久| 欧美色综合久久久久久| 国产午夜久久影院| 一本一本久久a久久精品综合麻豆| 精品久久久久久国产潘金莲| 一本一道久久a久久精品综合 | 99久久精品免费看国产| 久久久久久国产精品无码下载| 色综合久久久久| 国产精品久久久久久久久| 污污内射久久一区二区欧美日韩| 97久久精品午夜一区二区| 2021国内久久精品| 久久精品亚洲乱码伦伦中文| 天天爽天天爽天天片a久久网| 亚洲综合伊人久久综合| 亚洲人成无码久久电影网站| 国产福利电影一区二区三区久久久久成人精品综合 | 久久久久这里只有精品| 久久久久夜夜夜精品国产| 中文国产成人精品久久不卡| 7777精品伊人久久久大香线蕉| 午夜肉伦伦影院久久精品免费看国产一区二区三区 | 久久精品夜色噜噜亚洲A∨| 久久免费精品一区二区| 久久久91精品国产一区二区三区| 99热成人精品热久久669| 99久久人妻无码精品系列蜜桃| 狠狠干狠狠久久| 97精品国产97久久久久久免费| 久久精品九九亚洲精品天堂| 国产高清国内精品福利99久久|