青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

ACM___________________________

______________白白の屋
posts - 182, comments - 102, trackbacks - 0, articles - 0
<2025年11月>
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456

常用鏈接

留言簿(24)

隨筆分類(332)

隨筆檔案(182)

FRIENDS

搜索

積分與排名

最新隨筆

最新評(píng)論

閱讀排行榜

評(píng)論排行榜

MiYu原創(chuàng), 轉(zhuǎn)帖請(qǐng)注明 : 轉(zhuǎn)載自 ______________白白の屋    

題目地址 :

http://acm.hdu.edu.cn/showproblem.php?pid=3016

題目描述:

Man Down

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 618    Accepted Submission(s): 197


Problem Description
The Game “Man Down 100 floors” is an famous and interesting game.You can enjoy the game from 
http://hi.baidu.com/abcdxyzk/blog/item/16398781b4f2a5d1bd3e1eed.html

We take a simplified version of this game. We have only two kinds of planks. One kind of the planks contains food and the other one contains nails. And if the man falls on the plank which contains food his energy will increase but if he falls on the plank which contains nails his energy will decrease. The man can only fall down vertically .We assume that the energy he can increase is unlimited and no borders exist on the left and the right.

First the man has total energy 100 and stands on the topmost plank of all. Then he can choose to go left or right to fall down. If he falls down from the position (Xi,Yi),he will fall onto the nearest plank which satisfies (xl <= xi <= xr)(xl is the leftmost position of the plank and xr is the rightmost).If no planks satisfies that, the man will fall onto the floor and he finishes his mission. But if the man’s energy is below or equal to 0 , he will die and the game is Over.

Now give you the height and position of all planks. And ask you whether the man can falls onto the floor successfully. If he can, try to calculate the maximum energy he can own when he is on the floor.(Assuming that the floor is infinite and its height is 0,and all the planks are located at different height).
 

Input
There are multiple test cases.

For each test case, The first line contains one integer N (2 <= N <= 100,000) representing the number of planks.

Then following N lines representing N planks, each line contain 4 integers (h,xl,xr,value)(h > 0, 0 < xl < xr < 100,000, -1000 <= value <= 1000), h represents the plank’s height, xl is the leftmost position of the plank and xr is the rightmost position. Value represents the energy the man will increase by( if value > 0) or decrease by( if value < 0) when he falls onto this plank.
 

Output
If the man can falls onto the floor successfully just output the maximum energy he can own when he is on the floor. But if the man can not fall down onto the floor anyway ,just output “-1”(not including the quote)
 

Sample Input
4 10 5 10 10 5 3 6 -100 4 7 11 20 2 2 1000 10
 

Sample Output
140
 

 /*

  題目描述:  

          不同高度處有不同的水平板,跳到該板會(huì)有血量變化v,

          問當(dāng)一個(gè)人從最高板開始,可以向左或者向右,

          豎直跳到下面的板,求下落到地面的最大血量,或者-1。

          線段樹+dp  

          需要用線段樹查詢得到每個(gè)板的兩個(gè)端點(diǎn)下落后會(huì)到哪個(gè)板;

          然后根據(jù)這個(gè)從最高的開始dp就可以了

          dp[i] = max ( dp[i], dp[i^].v )  // dp[i^] 代表能走到 i 的線段 

/* 


/*

Mail to   : miyubai@gamil.com

Link      : http://www.cnblogs.com/MiYu  || http://m.shnenglu.com/MiYu

Author By : MiYu

Test      : 1

Complier  : g++ mingw32-3.4.2

Program   : HDU_3016

Doc Name  : Man Down

*/

//#pragma warning( disable:4789 )

#include <iostream>

#include <fstream>

#include <sstream>

#include <algorithm>

#include <string>

#include <set>

#include <map>

#include <utility>

#include <queue>

#include <stack>

#include <list>

#include <vector>

#include <cstdio>

#include <cstdlib>

#include <cstring>

#include <cmath>

#include <ctime>

using namespace std;

struct seg_tree {

    int id, left, right;

    int mid () { return ( left + right )>>1; }  

}seg[333333];

inline void creat ( int x, int y, int rt = 1 ) {

     seg[rt].left = x;

     seg[rt].right = y;

     //0 代表地面 其他的自然數(shù)代表各層的木板編號(hào)  -1 代表有多條線段覆蓋 

     seg[rt].id = 0;                  

     if ( x == y ) return ;

     int mid = seg[rt].mid();

     creat ( x, mid, rt << 1 );

     creat ( mid + 1, y, rt << 1 | 1 );     

}

inline void modify ( int x, int y, int id, int rt = 1 ) {

     //找到了線段, 直接修改ID 覆蓋掉 

     if ( seg[rt].left == x && seg[rt].right == y ) {

         seg[rt].id = id;

         return;   

     }

     int LL = rt << 1, RR = rt << 1 | 1, mid = seg[rt].mid();

     // 前面沒有return掉, 那么這條線段肯定是被覆蓋的, 將它的標(biāo)記下傳后標(biāo)記為-1 

     if ( seg[rt].id != -1 ) {      

         seg[LL].id = seg[RR].id = seg[rt].id;          

         seg[rt].id = -1;

     }      

     if ( y <= mid ) modify ( x, y, id, LL ); //分段修改 

     else if ( x > mid ) modify ( x, y, id, RR );

     else {

          modify ( x, mid, id, LL );

          modify ( mid + 1, y, id, RR );     

     }

}

inline int query ( int pos, int rt = 1 ) {   // 查詢 Pos 所在線段的 id  

    if ( seg[rt].id != -1 ) return seg[rt].id; //線段被覆蓋 直接返回 ID 

    int LL = rt << 1, RR = rt << 1 | 1, mid = seg[rt].mid();

    if ( pos <= mid ) return query ( pos, LL );             //分段查詢 

    else return query ( pos, RR );    

}

inline bool scan_d(int &num)  //整數(shù)輸入

{

        char in;bool IsN=false;

        in=getchar();

        if(in==EOF) return false;

        while(in!='-'&&(in<'0'||in>'9')) in=getchar();

        if(in=='-'){ IsN=true;num=0;}

        else num=in-'0';

        while(in=getchar(),in>='0'&&in<='9'){

                num*=10,num+=in-'0';

        }

        if(IsN) num=-num;

        return true;

}

struct Plank {

       int x,y,h,v,left,right; 

       //按高排序       

       friend bool operator < ( const Plank &a, const Plank &b ) {

              return a.h < b.h;

       }

}pk[100010];

int dp[100010];

int main ()

{

    int N, M;

    creat ( 1, 100000 );

    while ( scan_d ( N ) ) {

           M = -1;

           for ( int i = 1; i <= N; ++ i ) {

                scan_d ( pk[i].h );scan_d ( pk[i].x );scan_d ( pk[i].y );scan_d ( pk[i].v );

                if ( pk[i].y > M ) M = pk[i].y;       // 記錄 區(qū)間最大值, 加速用的 

           }

           modify  ( 1, M, 0 );

           sort ( pk + 1, pk + N + 1 );               // 按高排序 

           memset ( dp, 0, sizeof ( dp ) );

           dp[N] = 100 + pk[N].v;

           // 自底向上 更新 線段, 記錄 每條線段 左右端點(diǎn)能到達(dá)的 線段 ID 

           for ( int i = 1; i <= N; ++ i ) {          

                int x = pk[i].left = query ( pk[i].x );

                int y = pk[i].right = query ( pk[i].y );

                modify ( pk[i].x, pk[i].y, i );

           }

           int res = -1;

           //自頂向下 DP    dp[i] = max ( dp[i], dp[i^].v )  

           // dp[i^] 代表能走到 i 的線段 

           for ( int i = N; i >= 1; -- i ) {   

               if ( dp[ pk[i].left ] < dp[i] + pk[ pk[i].left ].v )

                    dp[ pk[i].left ] = dp[i] + pk[ pk[i].left ].v;

               if ( dp[ pk[i].right ] < dp[i] + pk[ pk[i].right ].v )

                    dp[ pk[i].right ] = dp[i] + pk[ pk[i].right ].v; 

           } 

           printf ( "%d\n",dp[0] > 0 ? dp[0] : -1 );

    }

    return 0;

}


 

 

Feedback

# re: HDU 3016 HDOJ 3016 Memory Control ACM 3016 IN HDU  回復(fù)  更多評(píng)論   

2010-10-18 19:21 by の屋
Google前n個(gè)搜索結(jié)果都和你的相關(guān)

# re: HDU 3016 HDOJ 3016 Man Down ACM 3016 IN HDU  回復(fù)  更多評(píng)論   

2010-10-30 07:51 by MiYu
表明哥 有 成 牛 的資質(zhì) =. = 嘿嘿

# re: HDU 3016 HDOJ 3016 Man Down ACM 3016 IN HDU  回復(fù)  更多評(píng)論   

2013-07-13 21:50 by fegnchen
pascal 版的有嗎??
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            欧美亚洲一级片| 久久男人av资源网站| 欧美日韩成人一区| 日韩网站免费观看| 日韩视频免费| 国产精品中文在线| 老司机67194精品线观看| 久久久欧美一区二区| 亚洲国产精品高清久久久| 欧美黑人一区二区三区| 欧美日本成人| 欧美在线一二三区| 久久在线播放| 这里只有精品视频| 午夜欧美理论片| 亚洲国产天堂久久综合| 99这里只有精品| 国产在线不卡精品| 亚洲人成亚洲人成在线观看图片| 欧美日韩国产探花| 久久久九九九九| 欧美日本国产视频| 久久精品久久99精品久久| 免费亚洲网站| 久久成人av少妇免费| 欧美gay视频激情| 欧美一区二区三区四区夜夜大片| 久久久精品一区| 亚洲男女自偷自拍| 欧美99久久| 久久精品人人做人人爽| 欧美精品久久一区| 巨乳诱惑日韩免费av| 欧美亚洲成人免费| 亚洲国产精品激情在线观看 | 欧美在线视频不卡| 开元免费观看欧美电视剧网站| 一区二区免费在线视频| 久久精品女人天堂| 欧美一二三区精品| 欧美人成在线| 欧美黑人一区二区三区| 国产网站欧美日韩免费精品在线观看 | 久久影音先锋| 国产精品视频最多的网站| 亚洲第一中文字幕| 精品99视频| 久久国产手机看片| 午夜一级在线看亚洲| 欧美日韩天天操| 亚洲久久一区二区| 亚洲人体1000| 久久亚洲春色中文字幕久久久| 欧美伊人精品成人久久综合97| 欧美激情中文不卡| 暖暖成人免费视频| 在线成人激情黄色| 久久精品国产亚洲一区二区三区 | 亚洲福利在线看| 欧美一区二视频在线免费观看| 亚洲一区久久久| 欧美日韩国产麻豆| 亚洲精品视频在线观看网站| 亚洲国产色一区| 欧美二区在线播放| 亚洲国产天堂久久国产91| 亚洲国产国产亚洲一二三| 久久精品伊人| 女主播福利一区| 亚洲激情一区二区三区| 猫咪成人在线观看| 亚洲高清精品中出| 亚洲天堂偷拍| 国产精品视频一区二区三区| 亚洲欧美日韩一区二区| 久久精品官网| 一区二区三区在线视频免费观看| 久久福利影视| 亚洲国产另类久久久精品极度| 亚洲精品一区二区三区四区高清| 欧美承认网站| 亚洲午夜黄色| 久久一日本道色综合久久| 亚洲高清精品中出| 欧美精品一区二区精品网| 99视频热这里只有精品免费| 亚洲欧美日韩国产另类专区| 国产女精品视频网站免费| 久久岛国电影| 亚洲欧洲三级| 欧美自拍偷拍午夜视频| 亚洲电影第三页| 欧美日韩中文在线| 久久黄色影院| 亚洲精品乱码久久久久| 午夜精品在线看| 亚洲国产第一| 国产麻豆日韩欧美久久| 久久综合中文| 亚洲女人小视频在线观看| 免费欧美日韩| 亚洲欧美日韩一区二区| 激情久久久久久久| 欧美午夜精品久久久久久久| 欧美在线一级va免费观看| 亚洲国产99| 久久久久久夜精品精品免费| 日韩一二三区视频| 国产亚洲一区二区精品| 欧美日韩黄色一区二区| 欧美在线视频一区| 99精品热视频只有精品10| 久久裸体艺术| 亚洲免费网址| 日韩视频免费观看高清完整版| 国产日韩1区| 欧美视频亚洲视频| 免费亚洲一区| 久久免费的精品国产v∧| 亚洲欧美日产图| 一区二区三区四区国产精品| 蜜臀av性久久久久蜜臀aⅴ四虎| 亚洲欧美怡红院| 一区二区三区**美女毛片| 在线精品高清中文字幕| 国产欧美一区二区精品忘忧草| 欧美日本不卡| 欧美a一区二区| 裸体女人亚洲精品一区| 久久国产主播| 久久国内精品视频| 欧美亚洲综合另类| 欧美一级片一区| 亚洲在线视频一区| 亚洲视频在线免费观看| 亚洲精品免费观看| 亚洲欧洲日韩综合二区| 亚洲国产精品v| 欧美风情在线观看| 免费中文字幕日韩欧美| 久久久久久久欧美精品| 久久久久久亚洲精品中文字幕| 欧美亚洲自偷自偷| 久久国产精品一区二区| 欧美一区二区三区婷婷月色| 亚洲一区二区三区777| 中文国产亚洲喷潮| 亚洲在线一区| 欧美一区激情| 久久综合一区二区| 欧美黄色一区| 亚洲欧洲在线观看| 亚洲麻豆视频| 亚洲一区二区三区四区中文 | 国产精品一区一区| 国产精品高清一区二区三区| 欧美日韩伊人| 国产精品视频网| 韩国女主播一区| 亚洲国产婷婷香蕉久久久久久99 | 国产精品久久网站| 国产伦精品一区二区三区视频黑人| 国产精品久久久久久久久免费樱桃 | 欧美一区在线直播| 久久久久久穴| 欧美激情一区二区三区高清视频| 欧美日韩福利在线观看| 国产精品国产| 精品动漫3d一区二区三区| 亚洲精品网址在线观看| 亚洲尤物在线视频观看| 久久精品盗摄| 亚洲欧洲一区二区三区| 亚洲永久免费视频| 欧美99久久| 国产精品资源在线观看| 1024成人| 午夜精品久久久久99热蜜桃导演| 久久久久久久久久久久久久一区| 亚洲国产毛片完整版| 亚洲欧美日韩成人| 欧美第一黄色网| 国产亚洲精品7777| 99这里只有久久精品视频| 久久久久久国产精品一区| 亚洲美女电影在线| 久久久久久亚洲综合影院红桃| 欧美日韩第一区日日骚| 一区二区在线观看视频在线观看| 亚洲午夜精品国产| 欧美国产日产韩国视频| 亚洲欧美日本日韩| 欧美日韩精品高清| 亚洲电影免费观看高清完整版在线观看 | 日韩视频在线观看| 久久亚洲精品中文字幕冲田杏梨| 一本色道久久99精品综合| 另类激情亚洲| 一区二区三区中文在线观看 | 亚洲大片av|