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

ACM___________________________

______________白白の屋
posts - 182, comments - 102, trackbacks - 0, articles - 0
<2013年7月>
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910

常用鏈接

留言簿(24)

隨筆分類(332)

隨筆檔案(182)

FRIENDS

搜索

積分與排名

最新隨筆

最新評論

閱讀排行榜

評論排行榜

MiYu原創, 轉帖請注明 : 轉載自 ______________白白の屋    

題目地址 :

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
 

 /*

  題目描述:  

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

          問當一個人從最高板開始,可以向左或者向右,

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

          線段樹+dp  

          需要用線段樹查詢得到每個板的兩個端點下落后會到哪個板;

          然后根據這個從最高的開始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 代表地面 其他的自然數代表各層的木板編號  -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掉, 那么這條線段肯定是被覆蓋的, 將它的標記下傳后標記為-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)  //整數輸入

{

        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;       // 記錄 區間最大值, 加速用的 

           }

           modify  ( 1, M, 0 );

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

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

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

           // 自底向上 更新 線段, 記錄 每條線段 左右端點能到達的 線段 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  回復  更多評論   

2010-10-18 19:21 by の屋
Google前n個搜索結果都和你的相關

# re: HDU 3016 HDOJ 3016 Man Down ACM 3016 IN HDU  回復  更多評論   

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

# re: HDU 3016 HDOJ 3016 Man Down ACM 3016 IN HDU  回復  更多評論   

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>
            欧美成年人视频网站欧美| 中日韩高清电影网| 一区二区激情视频| 亚洲全部视频| 欧美亚洲视频在线观看| 亚洲一区bb| 欧美人与禽性xxxxx杂性| 久久永久免费| 国产亚洲综合精品| 亚洲一区图片| 亚洲免费在线播放| 欧美午夜精品| 亚洲精品日韩激情在线电影 | 国产精品卡一卡二卡三| 最新精品在线| 亚洲第一主播视频| 久久久午夜精品| 久久久久.com| 好看的日韩视频| 欧美亚洲视频一区二区| 午夜精品一区二区三区在线视| 欧美日韩国产在线观看| 亚洲精品久久久蜜桃| 亚洲人成在线播放网站岛国| 免费观看国产成人| 亚洲电影天堂av| 亚洲美女91| 欧美日韩国产色视频| 亚洲毛片视频| 亚洲欧美在线免费观看| 国产精品久久77777| 亚洲永久免费| 久久精品一区中文字幕| 国产亚洲一区二区精品| 久久国内精品视频| 蜜桃av综合| 亚洲精品视频免费观看| 欧美黄色aaaa| 国产精品99久久久久久www| 亚洲免费网址| 国产日产精品一区二区三区四区的观看方式 | 亚洲夜晚福利在线观看| 午夜免费日韩视频| 国产一区二区三区在线观看视频| 欧美在线二区| 欧美激情久久久| 日韩亚洲欧美一区| 国产精品国产自产拍高清av| 亚洲欧美日韩精品在线| 久久最新视频| 亚洲美女色禁图| 国产伦精品一区二区三区高清版| 欧美亚洲一区二区三区| 亚洲国产精品99久久久久久久久| 一区二区日韩| 国产一区二区三区久久久| 久久亚洲精品一区二区| 日韩一级片网址| 欧美一区三区二区在线观看| 狠狠综合久久av一区二区小说| 欧美暴力喷水在线| 亚洲在线日韩| 亚洲国产精品福利| 午夜精品婷婷| 亚洲精品美女久久久久| 国产精品一区二区你懂的| 免费成人高清在线视频| 亚洲一区999| 欧美承认网站| 欧美永久精品| av不卡在线看| 狠狠做深爱婷婷久久综合一区| 欧美精品一卡| 久久精品国产在热久久 | 欧美有码在线观看视频| 亚洲精品国产拍免费91在线| 久久久久9999亚洲精品| 这里只有精品电影| 在线观看欧美成人| 国产欧美亚洲精品| 欧美日韩国产美| 鲁大师影院一区二区三区| 亚洲免费视频观看| 亚洲精品视频在线播放| 欧美sm视频| 久久久久久电影| 亚洲在线一区二区三区| 99国产精品久久久| 亚洲国产精品悠悠久久琪琪| 国产亚洲午夜| 国产精品一国产精品k频道56| 欧美电影资源| 猛男gaygay欧美视频| 欧美亚洲免费| 欧美一级在线播放| 亚洲视屏一区| 9久re热视频在线精品| 亚洲电影免费在线观看| 免费人成精品欧美精品| 久久久久国内| 久久精品一二三区| 欧美在线观看www| 午夜精彩国产免费不卡不顿大片| 日韩一级黄色av| 日韩视频在线永久播放| 亚洲精品影院在线观看| 亚洲激情在线| 亚洲片区在线| 亚洲免费黄色| 亚洲午夜久久久| 亚洲色图制服丝袜| 亚洲影视综合| 羞羞答答国产精品www一本| 亚洲免费视频网站| 欧美在线影院在线视频| 久久久精品一区二区三区| 久久九九国产| 美日韩丰满少妇在线观看| 欧美高清在线一区二区| 欧美精品综合| 国产精品美女久久久浪潮软件| 国产精品亚洲第一区在线暖暖韩国| 国产精品乱码久久久久久| 国产精品拍天天在线| 国产亚洲一级高清| 亚洲电影中文字幕| 亚洲作爱视频| 欧美亚洲在线观看| 久久亚洲色图| 91久久精品国产91性色| 亚洲激情偷拍| 亚洲午夜视频在线| 欧美一级久久久| 免费日韩成人| 欧美性猛交xxxx免费看久久久| 国产免费成人在线视频| 国内精品视频久久| 亚洲伦理中文字幕| 欧美一区二区三区四区高清| 免费欧美日韩| 日韩视频在线免费| 久久国产精品亚洲77777| 欧美二区在线| 国产精品久久久久9999| 亚洲电影有码| 亚洲女爱视频在线| 美女在线一区二区| 一区二区免费在线观看| 久久蜜桃精品| 国产精品高清在线| 亚洲成色777777在线观看影院| 一区二区三区国产精品| 久久久亚洲影院你懂的| 日韩午夜精品| 久久艳片www.17c.com| 国产精品麻豆va在线播放| 亚洲第一中文字幕| 午夜欧美视频| 亚洲精品极品| 久久久久一区二区| 国产精品婷婷午夜在线观看| 亚洲激情网站| 久久亚洲精品中文字幕冲田杏梨| 日韩网站免费观看| 欧美91福利在线观看| 国产在线精品自拍| 亚洲欧美99| 亚洲日本成人| 美日韩在线观看| 国语对白精品一区二区| 亚洲最新合集| 欧美国产成人精品| 久久九九热re6这里有精品| 国产精品ⅴa在线观看h| 亚洲精品免费一二三区| 久久中文字幕一区| 亚洲欧美日韩国产| 国产精品啊啊啊| 亚洲精品中文字幕女同| 免费在线成人| 久久久蜜桃精品| 国产亚洲欧美另类中文| 欧美一区=区| 亚洲婷婷综合久久一本伊一区| 欧美日本免费| 在线亚洲欧美| 亚洲日产国产精品| 欧美精品一区二区三区视频| 亚洲国产精品欧美一二99| 久久手机免费观看| 久久精品毛片| 一区二区三区中文在线观看 | 欧美黄色免费网站| 亚洲精品视频一区| 亚洲电影网站| 欧美激情亚洲另类| 亚洲视频电影在线| 亚洲视频高清| 国产日韩精品一区二区三区在线 | 小辣椒精品导航|