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

ACM___________________________

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

常用鏈接

留言簿(24)

隨筆分類(332)

隨筆檔案(182)

FRIENDS

搜索

積分與排名

最新隨筆

最新評論

閱讀排行榜

評論排行榜


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

 

題目地址:

 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
 

 

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

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

 

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

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

 

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

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

printf 會(huì)怎樣?   結(jié)果 :  1640 MS  AC ..............鬼知道他的 數(shù)據(jù)量有多大..... cout 和 printf

竟然 差了 5000 MS 的時(shí)間 ...........無語

代碼如下 :

 

 /*

Coded By  : MiYu

Link      : http://www.cnblogs.com/MiYu  || http://www.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>
            亚洲欧美激情一区| 99国内精品| 久久人人97超碰国产公开结果| 国产精品免费视频观看| 亚洲一二三级电影| 亚洲天堂av图片| 国产伦精品一区二区三区视频孕妇 | 久久精品欧美日韩| 欧美在线观看视频在线| 伊人成年综合电影网| 免费观看成人鲁鲁鲁鲁鲁视频| 久久亚洲春色中文字幕| 亚洲精品一级| 在线视频免费在线观看一区二区| 国产精品一区二区三区成人| 久久精品在线观看| 免费成人高清| 亚洲综合日本| 久久精品免费看| 日韩网站在线观看| 亚洲欧美成人| 91久久久在线| 亚洲午夜激情网页| 亚洲电影免费观看高清完整版| 亚洲激情av在线| 国产精品sss| 久色成人在线| 欧美日韩中文字幕在线| 久久久精品国产免费观看同学| 美脚丝袜一区二区三区在线观看| 久久精品国产77777蜜臀| 影音先锋在线一区| 欧美在线视频日韩| 亚洲日本一区二区三区| 亚洲色图在线视频| 亚洲高清123| 亚洲一品av免费观看| 在线 亚洲欧美在线综合一区| 99这里只有久久精品视频| 韩国成人精品a∨在线观看| 亚洲精品一二三| 国内精品国产成人| 亚洲深夜福利| 91久久国产综合久久| 欧美亚洲色图校园春色| 99re热这里只有精品视频 | 久久亚洲一区二区三区四区| 欧美乱人伦中文字幕在线| 久久久久成人精品免费播放动漫| 欧美日韩国产欧美日美国产精品| 免费久久99精品国产自| 国产精品有限公司| 亚洲国产精品久久久久婷婷老年| 国产一区二区三区在线观看免费视频| 亚洲精品永久免费精品| 亚洲区中文字幕| 久久视频免费观看| 久久久久国产一区二区三区四区| 国产精品v亚洲精品v日韩精品 | 久久久久久穴| 久久久久国产免费免费| 国产精品一区二区三区四区| 99在线观看免费视频精品观看| 亚洲人精品午夜| 久热精品视频在线观看| 老司机成人在线视频| 国产自产高清不卡| 午夜影视日本亚洲欧洲精品| 亚洲欧洲99久久| 国产精品毛片a∨一区二区三区|国 | 亚洲精品五月天| 免费观看一级特黄欧美大片| 蜜臀91精品一区二区三区| 国产一区二区三区日韩欧美| 欧美一区二区三区播放老司机| 篠田优中文在线播放第一区| 欧美日韩中文| 亚洲综合首页| 久久久欧美一区二区| 尤物视频一区二区| 免费成人激情视频| 亚洲精美视频| 亚洲视频在线二区| 国产精品视频一二三| 亚洲欧美成人一区二区三区| 久久精品一区二区| 在线精品国精品国产尤物884a| 牛牛影视久久网| 亚洲精品免费看| 亚洲欧美在线免费| 国产在线精品自拍| 美国十次了思思久久精品导航| 亚洲老板91色精品久久| 亚洲女女做受ⅹxx高潮| 国产视频在线观看一区二区| 久久综合国产精品| 亚洲精品欧美在线| 欧美中文在线视频| 在线精品观看| 国产精品国产精品| 久久国产精品第一页| 亚洲国产日韩在线一区模特| 亚洲欧美日韩精品一区二区| 国内激情久久| 欧美色大人视频| 久久精品国产一区二区电影 | 一本色道久久综合亚洲精品不卡 | 亚洲天堂av高清| 国产亚洲精品福利| 欧美成人午夜激情| 亚洲欧美成人一区二区三区| 亚洲成人直播| 久久激情网站| aaa亚洲精品一二三区| 国产性色一区二区| 欧美日韩另类在线| 久久婷婷人人澡人人喊人人爽| 日韩视频在线观看一区二区| 狂野欧美激情性xxxx欧美| 亚洲一区二区三区久久| 亚洲成色www久久网站| 国产精品v欧美精品v日韩| 麻豆精品视频| 欧美综合77777色婷婷| 日韩午夜免费视频| 欧美国产亚洲精品久久久8v| 欧美综合77777色婷婷| 亚洲视频中文字幕| 亚洲人人精品| 亚洲国产日本| 激情久久久久| 国产亚洲精品久久久久久| 欧美日韩一区二区三区| 欧美成va人片在线观看| 久久人人爽人人爽爽久久| 午夜精品福利一区二区三区av| 99热精品在线观看| 91久久嫩草影院一区二区| 欧美成人精精品一区二区频| 久久久www| 久久国产夜色精品鲁鲁99| 亚洲欧美日韩国产一区二区三区| 一道本一区二区| 99riav1国产精品视频| 亚洲国产婷婷综合在线精品 | 亚洲高清av在线| 激情视频亚洲| 国外成人免费视频| 狠狠入ady亚洲精品经典电影| 国产一区二区精品| 国产亚洲欧美日韩日本| 国产亚洲精品久久飘花| 国产午夜久久| 一色屋精品视频在线观看网站| 国产亚洲一区二区三区在线播放| 国产午夜精品美女视频明星a级| 国产乱人伦精品一区二区| 国产一区二区黄色| 激情婷婷亚洲| 亚洲精品久久7777| 欧美国产激情二区三区| 欧美r片在线| 欧美va日韩va| 欧美日韩在线视频一区| 欧美视频在线看| 国产欧美1区2区3区| 国产精品视频区| 永久久久久久| 亚洲久久在线| 性欧美大战久久久久久久久| 久久精品2019中文字幕| 理论片一区二区在线| 免费欧美高清视频| 亚洲精品美女| 亚洲欧美中日韩| 蜜桃精品久久久久久久免费影院| 欧美久久久久中文字幕| 国产精品美女久久| 伊人成人网在线看| 香蕉av777xxx色综合一区| 欧美一区二区在线| 美日韩精品视频| 99精品黄色片免费大全| 亚洲免费在线电影| 久久综合一区二区| 国产精品v欧美精品v日本精品动漫| 国产日韩精品一区二区三区 | 亚洲一区二区免费| 久久久久久午夜| 国产精品www色诱视频| 精品91久久久久| 亚洲一区精品视频| 欧美高清视频免费观看| 亚洲午夜久久久久久久久电影院 | 欧美国产第一页| 国产一区二区视频在线观看| 亚洲精品欧美| 麻豆国产va免费精品高清在线| 99亚洲一区二区| 欧美成年人网站|