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

ACM___________________________

______________白白の屋
posts - 182, comments - 102, trackbacks - 0, articles - 0
<2010年9月>
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789

常用鏈接

留言簿(24)

隨筆分類(332)

隨筆檔案(182)

FRIENDS

搜索

積分與排名

最新隨筆

最新評論

閱讀排行榜

評論排行榜


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

 

題目地址:

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

題目描述:

Billboard

Time Limit: 20000/8000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 733    Accepted Submission(s): 340


Problem Description
At the entrance to the university, there is a huge rectangular billboard of size h*w (h is its height and w is its width). The board is the place where all possible announcements are posted: nearest programming competitions, changes in the dining room menu, and other important information.

On September 1, the billboard was empty. One by one, the announcements started being put on the billboard.

Each announcement is a stripe of paper of unit height. More specifically, the i-th announcement is a rectangle of size 1 * wi.

When someone puts a new announcement on the billboard, she would always choose the topmost possible position for the announcement. Among all possible topmost positions she would always choose the leftmost one.

If there is no valid location for a new announcement, it is not put on the billboard (that's why some programming contests have no participants from this university).

Given the sizes of the billboard and the announcements, your task is to find the numbers of rows in which the announcements are placed.
 

Input
There are multiple cases (no more than 40 cases).

The first line of the input file contains three integer numbers, h, w, and n (1 <= h,w <= 10^9; 1 <= n <= 200,000) - the dimensions of the billboard and the number of announcements.

Each of the next n lines contains an integer number wi (1 <= wi <= 10^9) - the width of i-th announcement.
 

Output
For each announcement (in the order they are given in the input file) output one number - the number of the row in which this announcement is placed. Rows are numbered from 1 to h, starting with the top row. If an announcement can't be put on the billboard, output "-1" for this announcement.
 

Sample Input
3 5 5 2 4 3 3 3
 

Sample Output
1 2 1 3 -1
 

 

一開始沒想明白怎么做 ,  仔細想了想,   再次 讀題后 發現 , n <= 200000;  也就是說  最多 也就 200000 條廣告 , 你就算每行貼一張 ,

最多也就貼到 200000 行,  所以  不要被  h <= 10^9  次方嚇到了  ,認為 線段樹開不了那么大的數組  . 只要開 200000 就可以了 .

 

其他的 沒什么 好說的 , 知道這個 就直接 暴 吧 ............將近 7000MS .=水過.................   g++提交 還華麗的 送出了 一次 TLE....

C++  水過了 ............

 

//    一直沒明白 為什么我的 代碼速度 那么 慢,  查詢后 更新 的時間是 2000MS 左右  , 我的 是 查詢 就更新了,

竟然要 將近 7000MS ? 非常 郁悶 ,  不信邪的 繼續 檢查 代碼, 在 瞪了 1哥小時后 , 忽然想到 : 把 cout 改成

printf 會怎樣?   結果 :  1640 MS  AC ..............鬼知道他的 數據量有多大..... cout 和 printf

竟然 差了 5000 MS 的時間 ...........無語

代碼如下 :

 

 /*

Coded By  : MiYu

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

Author By : MiYu

Test      : 1

Program   : 2795

*/

//#pragma warning( disable:4789 )

#include <iostream>

#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>

using namespace std;


struct ADV {

       int left, right, val;

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

}adv[800000];

int N, W, H, w;

void creat ( int l, int r, int rt = 1 ){

     adv[rt].left = l;

     adv[rt].right = r;

     adv[rt].val = W;

     if ( l == r )

        return ;

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

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

     creat ( mid + 1, r, ( rt << 1 ) + 1 );

}

void add ( int rt = 1, int wei = w ){

    if ( wei <= adv[rt].val ){

         if ( adv[rt].left == adv[rt].right ){

              adv[rt].val -= wei;

              //cout << adv[rt].left << endl;  //杯具的 地方

printf ( "%d\n", adv[rt].left ); 

              return ;     

         } else if ( adv[rt<<1].val >= wei ) {

                add ( rt << 1 );

                adv[rt].val = max ( adv[rt<<1].val, adv[(rt<<1)+1].val );     

         } else {

                add ( ( rt << 1 ) + 1 );

                adv[rt].val = max ( adv[rt<<1].val, adv[(rt<<1)+1].val );        

         }   

    } else {

           //cout << -1 << endl;      //杯具的地方

puts ( "-1" );   

    }   

}

inline bool scan_ud(int &num)

{

    char in;

    in=getchar();

    if(in==EOF) return false;

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

    num=in-'0';

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

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

    }

    return true;

}

int main ()

{

    while ( scan_ud (H)&&scan_ud (W)&&scan_ud (N) ) {

           if ( H > 200000 )

               H = 200010;

           creat ( 1, H );

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

                scan_ud (w);

                add ( );     

           }      

    }

    return 0;

}

 

 

 

 

另 附上 傻崽  神牛 代碼 :

 

#include <iostream>

#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>

#define FF(i,a) for( int i = 0 ; i < a ; i ++ )

#define FOR(i,a,b) for( int i = a ; i < b ; i ++ )

#define LL(a) a<<1

#define RR(a) a<<1|1

template<class T> inline void checkmin(T &a,T b) {if(a < 0 || a > b)a = b;}

template<class T> inline void checkmax(T &a,T b) {if(a < b) a = b;}

using namespace std;

struct Node {

int val;

int idx;

friend bool operator < (Node a , Node b) {

if(a.val == b.val) {

return a.idx > b.idx;

}

return a.val < b.val;

}

}error;

 

struct Seg_Tree{

int left,right;

Node node;

int mid() {

return (left + right)>>1;

}

}tt[800000];

 

int n , h , m;

 

void build(int l,int r,int idx) {

tt[idx].left = l;

tt[idx].right = r;

tt[idx].node.idx = l;

tt[idx].node.val = h;

if(l == r) return ;

int mid = tt[idx].mid();

build(l,mid,LL(idx));

build(mid+1,r,RR(idx));

}

 

void update(int l,int r,int val,int idx) {

if(l <= tt[idx].left && r >= tt[idx].right) {

tt[idx].node.val += val;

return ;

}

int mid = tt[idx].mid();

if(l <= mid) update(l,r,val,LL(idx));

if(mid < r) update(l,r,val,RR(idx));

tt[idx].node = max(tt[LL(idx)].node,tt[RR(idx)].node);

}

 

Node query(int w,int idx) {

if(tt[idx].node.val < w) {

return error;

}

if(tt[idx].left == tt[idx].right) {

return tt[idx].node;

}

if(tt[LL(idx)].node.val >= w) {

return query(w,LL(idx));

} else {

return query(w,RR(idx));

}

}

 

int main() {

error.idx = -1;

while(scanf("%d%d%d",&n,&h,&m) == 3) {

checkmin(n,m);

build(1,n,1);

while(m --) {

int w;

scanf("%d",&w);

Node ret = query(w,1);

printf("%d\n",ret.idx);

if(ret.idx != -1) {

update(ret.idx,ret.idx,-w,1);

}

}

}

return 0;

 

 

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            欧美日韩国产黄| 久久综合给合久久狠狠狠97色69| 一区二区高清视频| 欧美激情第三页| 国产亚洲成av人片在线观看桃 | 亚洲自拍都市欧美小说| 欧美日韩三级| 亚洲一区日本| 亚洲一区二区成人在线观看| 国产精品久久久久久久久久久久久久| 亚洲精品在线免费| 亚洲欧洲精品一区二区三区不卡| 女人天堂亚洲aⅴ在线观看| 欧美色大人视频| 欧美一区二区视频网站| 久久国产精品久久久久久| 国产精品亚洲片夜色在线| 欧美伊人久久久久久午夜久久久久 | 欧美精品成人91久久久久久久| 在线观看精品一区| 亚洲国产免费看| 欧美成人综合网站| 欧美一级理论性理论a| 久久综合九色综合网站| 亚洲制服av| 久久综合五月| 香蕉成人久久| 欧美国产视频在线观看| 欧美在线亚洲在线| 欧美精品观看| 久久综合狠狠综合久久综青草 | 国产精品高潮呻吟| 欧美高清成人| 国产亚洲精品久久久| 亚洲精品乱码| 亚洲韩国日本中文字幕| 亚洲欧美日韩综合aⅴ视频| 亚洲欧洲日本一区二区三区| 午夜精品www| 亚洲专区欧美专区| 欧美精品激情blacked18| 久久人人九九| 国产一区二区日韩精品欧美精品| 亚洲日本va午夜在线影院| 永久91嫩草亚洲精品人人| 亚洲欧美日韩精品久久久久| 中文久久精品| 欧美国产视频在线观看| 美腿丝袜亚洲色图| 狠狠色综合网站久久久久久久| 亚洲自拍偷拍麻豆| 亚洲欧美日韩一区二区三区在线| 欧美高清视频| 国产欧美日本| 亚洲欧美在线看| 欧美在线看片| 国产欧美一区二区三区视频| 制服丝袜激情欧洲亚洲| 亚洲一级特黄| 国产精品每日更新| 亚洲在线网站| 欧美在线欧美在线| 国产一区二区精品久久| 欧美专区中文字幕| 久久精品一区| 尤物精品在线| 欧美 亚欧 日韩视频在线| 亚洲第一主播视频| 夜夜狂射影院欧美极品| 欧美日韩成人一区| 99精品国产一区二区青青牛奶| 夜夜嗨av一区二区三区网页| 欧美日韩亚洲视频| 亚洲综合色在线| 久久天堂成人| 亚洲精品欧洲| 国产精品海角社区在线观看| 亚洲图片欧美午夜| 久久视频在线看| 亚洲精品国产精品乱码不99按摩 | 久久狠狠久久综合桃花| 美女爽到呻吟久久久久| 亚洲精品九九| 欧美日韩综合不卡| 欧美在线999| 亚洲激情视频在线观看| 亚洲在线观看免费| 国产一区日韩一区| 男男成人高潮片免费网站| 一区二区三区免费网站| 久久久99免费视频| 日韩亚洲欧美成人| 国产精品一区二区视频| 久久久亚洲精品一区二区三区| 亚洲激情视频在线播放| 欧美一级淫片播放口| 91久久视频| 国产女人aaa级久久久级| 老司机免费视频久久| 99视频有精品| 美女精品在线观看| 亚洲一区二区三区色| 一区二区亚洲| 欧美日韩亚洲网| 久久婷婷综合激情| 亚洲一区国产一区| 亚洲国产综合91精品麻豆| 性一交一乱一区二区洋洋av| 狠狠88综合久久久久综合网| 欧美激情第五页| 久久九九99| 亚洲综合丁香| 一二三区精品| 亚洲国产视频一区二区| 久久亚洲午夜电影| 午夜精品视频一区| 一区二区国产日产| 亚洲国产综合视频在线观看| 国产午夜精品一区二区三区欧美 | 国产精品video| 欧美va天堂va视频va在线| 香蕉成人伊视频在线观看| 日韩一本二本av| 亚洲国产一区二区三区a毛片 | 99亚洲一区二区| 亚洲国产91| 国产一区二区三区最好精华液| 欧美日韩国产成人高清视频| 久久夜色精品一区| 久久久一本精品99久久精品66| 亚洲一区国产| 亚洲桃花岛网站| 9l视频自拍蝌蚪9l视频成人| 亚洲国产裸拍裸体视频在线观看乱了| 美女脱光内衣内裤视频久久网站| 欧美在线综合视频| 久久爱www| 久久久久久国产精品一区| 久久久999精品免费| 欧美在线观看日本一区| 欧美在线影院在线视频| 欧美在线亚洲一区| 久久久久久久久久久久久女国产乱| 羞羞漫画18久久大片| 欧美在线视频在线播放完整版免费观看 | 午夜亚洲福利在线老司机| 亚洲欧美大片| 欧美一级黄色录像| 欧美一级在线亚洲天堂| 久久成人国产精品| 久久蜜臀精品av| 免费视频一区| 欧美三区美女| 国产婷婷97碰碰久久人人蜜臀| 国产一区二区久久精品| 在线日本成人| 亚洲精品一区久久久久久| 在线综合亚洲欧美在线视频| 亚洲欧美国产不卡| 久久久久一区二区三区| 欧美国产精品久久| 99精品视频免费全部在线| 亚洲婷婷综合色高清在线| 欧美专区第一页| 欧美成人精品一区| 国产精品二区影院| 精品不卡在线| 99精品热视频| 欧美在线视频二区| 欧美寡妇偷汉性猛交| 一区二区三区视频在线| 亚洲欧美日韩国产中文| 免费不卡中文字幕视频| 欧美日韩亚洲国产一区| 国产主播在线一区| 99视频在线精品国自产拍免费观看| 亚洲欧美欧美一区二区三区| 久久天天综合| 99在线热播精品免费| 久久久久久久久久久久久女国产乱| 欧美国产日韩一区| 国产在线欧美| 亚洲午夜免费视频| 欧美激情第六页| 性高湖久久久久久久久| 欧美精品免费在线观看| 精品99一区二区三区| 亚洲免费视频观看| 亚洲国产欧美日韩精品| 欧美综合激情网| 欧美性做爰毛片| 亚洲精品国产欧美| 久久野战av| 亚洲一区二区三区精品在线| 欧美高清一区| 亚洲国产精品久久人人爱蜜臀| 欧美亚洲免费高清在线观看| 亚洲第一综合天堂另类专| 久久九九99视频| 国产中文一区|