• <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>
            posts - 74,  comments - 33,  trackbacks - 0
             
            Time Limit: 3000MS Memory Limit: 65536K
            Total Submissions: 5593 Accepted: 878

            Description

            triDesign company produces different logical games and puzzles for children. One of the games called triSuper is basically a set of sticks. The length of a stick is measured in millimeters and some of sticks in a set may be of the same length.

            Authors of the game think for some reason that a child being given a triSuper game set uses the sticks to construct triangles. Doing so, the child will eventually realize that it is not always possible to construct a triangle from any three sticks. This is the educational value of the game – to study “the inequality of a triangle”.

            A particular feature of the game is that each game set is unique. Furthermore, each game set is tested after production. The game set is rejected if it breaks any of the following rules.

            1. None three sticks from the set can be used to construct a triangle.
            2. Any three sticks from the set can be used to construct a triangle.

            As far as a game set may contain a lot of sticks, it is necessary to develop special program to help testing game sets. This is what you need to do.

            Input

            The input describes one game set. The first line of the input contains an integer number N (1 ≤ N ≤ 1 000 000). The second line contains N integer numbers A1, A2, …, AN, separated by spaces (1 ≤ Ai ≤ 2 000 000 000). Ai is the length of the stick number i in the set. Sticks in the set a so thin, that you can disregard their thickness.

            Output

            The output has to contain a single line. If a game set is rejected than the line is “The set is rejected.”. Otherwise, the line is “The set is accepted.”

            Sample Input

            sample input #1
            3
            1 2 3
            sample input #2
            4
            4 4 4 4
            sample input #3
            4
            1 2 3 4

            Sample Output

            sample output #1
            The set is rejected.
            sample output #2
            The set is rejected.
            sample output #3
            The set is accepted.

            如果說這是道水題的話,前提是你能提高輸入的效率!
            C++的cin肯定是不行的,C的scanf在這海量的數據面前也顯得有些蒼白無力,所以只能自己寫字節讀入函數來輸入數據
             
            我寫的讀入函數在下面(參考過資料)
             1int in(int a)
             2{
             3    int sum=0;
             4    char ch;
             5    getchar();
             6    while((ch=getchar())!=EOF)
             7    {
             8        if(ch<='9'&&ch>='0')sum=sum*10+ch-'0';
             9        else 
            10        {
            11            s[a++]=sum;
            12            sum=0;    
            13        }

            14    }

            15    return 1;    
            16}

            而思路與原來一樣,可是這樣之后的提交就是一次AC 1110ms。
             我的優化思路還是沒有AC
            思路如下:
            Dissicion里面說Fibnacci 函數來限制sort的范圍因為 1 1  2  3  5  8  13  21 可以是三角形的臨界情況,大概是 F(46)是int的上限
            可是一直WA,實在是搞不明白自己哪里錯了。
            輸入的時候我提取的最小的兩個數最大的一個數的代碼如下
             1 int in(int a)
             2 {
             3     int sum=0;
             4     char ch;
             5     getchar();
             6     while((ch=getchar())!=EOF)
             7     {
             8         if(ch<='9'&&ch>='0')sum=sum*10+ch-'0';
             9         else 
            10         {
            11             s[a++]=sum;
            12             sum=0;
            13             if(s[a-1]>Max)Max=s[a-1];
            14             if(s[a-1]<min1)
            15             {
            16                 min2=min1;
            17                 min1=s[a-1];
            18             }
            19             else if(s[a-1]<min2)min2=s[a-1];    
            20         }
            21     }
            22     return 1;    
            23 }

            提交很多次大概有40左右次吧,優化思路還是沒有AC,有個牛人要請我吃飯了
            posted on 2008-12-22 11:15 KNIGHT 閱讀(416) 評論(1)  編輯 收藏 引用

            FeedBack:
            # re: POJ 2967 Triangles
            2008-12-25 12:37 | Knight
            思路沒錯,因為寫的時候
            有了min1+min2<=MAX存在了溢出問題。。。。所以WA了
            改了之后排名第四516msAC  回復  更多評論
              
            <2009年2月>
            25262728293031
            1234567
            891011121314
            15161718192021
            22232425262728
            1234567

            常用鏈接

            留言簿(8)

            隨筆檔案

            文章檔案

            Friends

            OJ

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            日本精品一区二区久久久| 日本免费久久久久久久网站| 久久久国产打桩机| 久久亚洲春色中文字幕久久久 | 久久夜色精品国产噜噜麻豆| 人妻无码αv中文字幕久久琪琪布 人妻无码久久一区二区三区免费 人妻无码中文久久久久专区 | 国产亚洲色婷婷久久99精品91| 久久97久久97精品免视看| 久久青青色综合| 情人伊人久久综合亚洲| 久久久久久伊人高潮影院| 国产V综合V亚洲欧美久久| 久久亚洲电影| 99久久国产主播综合精品| 久久午夜福利无码1000合集| 青青草国产精品久久久久| 一本久久a久久精品亚洲| 久久久久人妻一区精品果冻| 亚洲AV无码一区东京热久久| 亚洲国产精品一区二区三区久久 | 久久久久久久久久久免费精品| 久久影院综合精品| 久久99热这里只有精品66| 国产精品99久久久久久猫咪| 精品国产乱码久久久久久郑州公司| 久久人人超碰精品CAOPOREN| 精品精品国产自在久久高清 | 久久99精品国产麻豆蜜芽| 72种姿势欧美久久久久大黄蕉| A级毛片无码久久精品免费 | 久久久久四虎国产精品| 欧美牲交A欧牲交aⅴ久久 | 国产精品久久久久久影院| 嫩草伊人久久精品少妇AV| 国产激情久久久久久熟女老人| 思思久久好好热精品国产| 久久久久久毛片免费看| 久久久久久国产精品免费免费| 久久国产成人午夜aⅴ影院| 久久国产午夜精品一区二区三区| 久久精品国产精品亚洲艾草网美妙|