• <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 
            四虎影视久久久免费观看| 久久亚洲精品成人无码网站| 人妻精品久久无码区 | 国产99精品久久| 久久久久亚洲精品天堂久久久久久| 久久天天躁狠狠躁夜夜av浪潮| 精品人妻伦九区久久AAA片69| 国产精品久久久久久福利漫画| 久久精品亚洲乱码伦伦中文| 久久综合狠狠综合久久| 精品人妻伦九区久久AAA片69| 久久国产欧美日韩精品| 伊人久久大香线蕉综合5g| .精品久久久麻豆国产精品| 色综合久久天天综线观看| 久久99国产精品久久| 无码精品久久久久久人妻中字 | 国产V综合V亚洲欧美久久| 一本一道久久a久久精品综合| 99国产精品久久久久久久成人热| 亚洲精品美女久久久久99小说| 色综合久久88色综合天天| 久久亚洲私人国产精品| 亚洲国产精品无码久久98| 中文字幕无码久久人妻| 久久亚洲视频| 精品乱码久久久久久夜夜嗨| 久久精品国产99国产电影网 | 97精品依人久久久大香线蕉97 | 久久精品水蜜桃av综合天堂| 久久精品夜色噜噜亚洲A∨| 久久99国产综合精品免费| 亚洲国产精品无码久久久久久曰| 狠狠干狠狠久久| 青青草国产精品久久久久| 日本三级久久网| 国内精品欧美久久精品| 久久国产成人午夜AV影院| 亚洲国产精品无码久久久久久曰| 欧美成a人片免费看久久| 亚洲AⅤ优女AV综合久久久|