• <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.

            如果說(shuō)這是道水題的話(huà),前提是你能提高輸入的效率!
            C++的cin肯定是不行的,C的scanf在這海量的數(shù)據(jù)面前也顯得有些蒼白無(wú)力,所以只能自己寫(xiě)字節(jié)讀入函數(shù)來(lái)輸入數(shù)據(jù)
             
            我寫(xiě)的讀入函數(shù)在下面(參考過(guò)資料)
             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}

            而思路與原來(lái)一樣,可是這樣之后的提交就是一次AC 1110ms。
             我的優(yōu)化思路還是沒(méi)有AC
            思路如下:
            Dissicion里面說(shuō)Fibnacci 函數(shù)來(lái)限制sort的范圍因?yàn)?1 1  2  3  5  8  13  21 可以是三角形的臨界情況,大概是 F(46)是int的上限
            可是一直WA,實(shí)在是搞不明白自己哪里錯(cuò)了。
            輸入的時(shí)候我提取的最小的兩個(gè)數(shù)最大的一個(gè)數(shù)的代碼如下
             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左右次吧,優(yōu)化思路還是沒(méi)有AC,有個(gè)牛人要請(qǐng)我吃飯了
            posted on 2008-12-22 11:15 KNIGHT 閱讀(416) 評(píng)論(1)  編輯 收藏 引用

            FeedBack:
            # re: POJ 2967 Triangles
            2008-12-25 12:37 | Knight
            思路沒(méi)錯(cuò),因?yàn)閷?xiě)的時(shí)候
            有了min1+min2<=MAX存在了溢出問(wèn)題。。。。所以WA了
            改了之后排名第四516msAC  回復(fù)  更多評(píng)論
              

            只有注冊(cè)用戶(hù)登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問(wèn)   Chat2DB   管理


            <2009年5月>
            262728293012
            3456789
            10111213141516
            17181920212223
            24252627282930
            31123456

            常用鏈接

            留言簿(8)

            隨筆檔案

            文章檔案

            Friends

            OJ

            搜索

            •  

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            无码超乳爆乳中文字幕久久| 国产精品久久久亚洲| 久久亚洲AV无码西西人体| 久久人搡人人玩人妻精品首页| 香蕉aa三级久久毛片| 人妻精品久久无码专区精东影业| 色综合久久综合中文综合网| 久久91精品久久91综合| 亚洲国产成人久久精品99 | 成人久久免费网站| 欧洲精品久久久av无码电影| 国产午夜精品理论片久久| 久久精品国产久精国产一老狼| 77777亚洲午夜久久多喷| 香蕉99久久国产综合精品宅男自| 久久精品麻豆日日躁夜夜躁| 精品久久久久久无码中文野结衣 | 精品欧美一区二区三区久久久| 亚洲?V乱码久久精品蜜桃 | 伊人精品久久久久7777| 精品亚洲综合久久中文字幕| 要久久爱在线免费观看| 久久精品国产精品国产精品污| 7777久久久国产精品消防器材| 久久久久亚洲AV无码专区网站| 狠狠色丁香久久婷婷综合五月| 亚洲欧美日韩久久精品| 91精品国产高清久久久久久91| 18岁日韩内射颜射午夜久久成人| 久久99精品久久久久久9蜜桃| 国产精品久久久久9999| 久久久久久久久无码精品亚洲日韩| 婷婷久久精品国产| 欧美亚洲另类久久综合婷婷| 狠狠色伊人久久精品综合网| 91亚洲国产成人久久精品| 国产精品久久久久9999| 久久婷婷综合中文字幕| 久久精品国产亚洲网站| 久久久精品一区二区三区| 久久亚洲国产精品一区二区|