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

ACM___________________________

______________白白の屋
posts - 182, comments - 102, trackbacks - 0, articles - 0
<2010年8月>
25262728293031
1234567
891011121314
15161718192021
22232425262728
2930311234

常用鏈接

留言簿(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>
            91久久精品国产91久久性色| 欧美黄色网络| 久久久蜜臀国产一区二区| 久久久午夜电影| 国内在线观看一区二区三区| 亚洲另类在线视频| 国产精品久久久一区二区| 韩国一区二区三区在线观看| 久久米奇亚洲| 日韩一区二区免费看| 欧美一区二区三区在线观看视频| 亚洲最黄网站| 久久综合精品国产一区二区三区| 久久国产精品72免费观看| 欧美成人精精品一区二区频| 国产欧美精品一区二区三区介绍| 国产精品私拍pans大尺度在线 | 宅男在线国产精品| 欧美伊人久久久久久午夜久久久久| 黄色在线一区| 一区二区三区在线免费播放| 欧美黑人一区二区三区| 亚洲男女自偷自拍| 欧美精品手机在线| 最新中文字幕亚洲| 在线亚洲电影| 欧美日韩日本视频| 亚洲国产精品黑人久久久| 91久久夜色精品国产网站| 91久久精品国产91久久性色tv| 亚洲第一网站免费视频| 欧美在线亚洲一区| 一区二区三区偷拍| 黄色日韩网站视频| 99精品国产在热久久婷婷| 国产主播一区二区三区四区| 久久人人超碰| 欧美特黄一级大片| 亚洲欧美激情精品一区二区| 一区二区高清在线观看| 午夜日韩av| 国产一区在线视频| 亚洲免费观看在线视频| 精品成人免费| 亚洲欧美日韩精品一区二区| 国产自产精品| 一本色道久久综合亚洲精品小说 | 久久精品国产亚洲aⅴ| 一区二区三区日韩精品视频| 一区二区成人精品| 亚洲国产岛国毛片在线| 欧美在线播放一区| 在线观看福利一区| 欧美激情精品久久久久久蜜臀 | 亚洲午夜女主播在线直播| 国产精品久久看| 亚洲国语精品自产拍在线观看| 香蕉成人啪国产精品视频综合网| 国产精品中文字幕在线观看| 久久精品成人一区二区三区蜜臀 | 亚洲免费中文字幕| 欧美激情综合| 亚洲欧洲日本在线| 国产精品午夜在线观看| 老牛国产精品一区的观看方式| 99re6这里只有精品| 亚洲福利久久| 美国成人直播| 欧美在线啊v一区| 国产精品网曝门| 亚洲一区二区在线播放| 亚洲电影在线| 狂野欧美激情性xxxx| 欧美成年人网站| 国产精品久久久久久影院8一贰佰 国产精品久久久久久影视 | 久久国产精品色婷婷| 欧美一区二区在线免费观看| 国产精品一二三视频| 午夜精品久久99蜜桃的功能介绍| 亚洲国产另类精品专区| 亚洲精品在线观看免费| 国内精品视频666| 久久久国产成人精品| 亚洲欧美日韩国产一区| 国产精品美女久久久| 亚洲欧美激情一区| 亚洲精品视频免费| 亚洲激情av在线| 中文有码久久| 欧美成人一区二区三区片免费| 欧美一区二区三区日韩视频| 欧美高清视频免费观看| 99精品国产一区二区青青牛奶| 亚洲风情亚aⅴ在线发布| 欧美激情在线狂野欧美精品| 一区二区三区国产盗摄| 久久狠狠亚洲综合| 亚洲精品欧洲| 国产精品色网| 宅男精品视频| 这里只有精品电影| 国内精品久久久久伊人av| 欧美顶级大胆免费视频| 在线综合+亚洲+欧美中文字幕| 日韩网站在线看片你懂的| 狂野欧美性猛交xxxx巴西| 亚洲精品视频啊美女在线直播| 亚洲高清免费| 老司机午夜免费精品视频| 最近中文字幕日韩精品| 亚洲精品五月天| 国产女人aaa级久久久级| 免费h精品视频在线播放| 一本色道久久88综合日韩精品 | 欧美日韩1区| 欧美激情一区二区三区不卡| 黄色成人在线免费| 欧美日韩黄色一区二区| 欧美一区1区三区3区公司| 亚洲精品专区| 亚洲大胆美女视频| 亚洲精品久久久久久久久久久久| 久久精品在线播放| 亚洲最新视频在线播放| 欧美高清视频免费观看| 国产精品海角社区在线观看| 一本色道久久综合狠狠躁篇怎么玩| 夜夜嗨av一区二区三区网站四季av | 99国产精品久久久久老师| 国产一区二区三区在线观看免费| 亚洲黄色精品| 老司机精品导航| 久久国产精品99国产| 亚洲专区一区| 好吊妞**欧美| 国产偷国产偷精品高清尤物| 巨胸喷奶水www久久久免费动漫| 欧美成人资源网| 久久久99爱| 一区二区三区欧美亚洲| 亚洲福利国产| 亚洲国产美国国产综合一区二区| 欧美精品一区三区| 欧美一区二区在线免费观看 | 99精品国产99久久久久久福利| 欧美日韩中文字幕| 欧美日韩成人免费| 欧美日本一区二区视频在线观看| 亚洲一二三区精品| 在线综合亚洲欧美在线视频| 久久久精品一区| 久久欧美中文字幕| 在线综合亚洲欧美在线视频| 国产亚洲一区在线播放| 国产情侣一区| 狠狠色丁香久久婷婷综合丁香| 欧美日韩精品一本二本三本| 欧美激情一区二区三区成人| 欧美高清视频在线| 欧美精品九九99久久| 欧美欧美全黄| 国产精品进线69影院| 美乳少妇欧美精品| 欧美成人午夜77777| 欧美精品综合| 国产精品久久久久久久9999| 国产伦一区二区三区色一情| 国产综合香蕉五月婷在线| 欧美日韩国产综合视频在线观看中文 | 亚洲欧美日韩专区| 羞羞色国产精品| 久久亚洲综合| 香蕉久久精品日日躁夜夜躁| 久久福利电影| 免费在线看成人av| 久久―日本道色综合久久| 免费中文字幕日韩欧美| 欧美日韩播放| 国产亚洲综合性久久久影院| 亚洲高清一区二区三区| 亚洲作爱视频| 亚洲精品黄色| 性欧美videos另类喷潮| 亚洲一区三区电影在线观看| 亚洲精品一区二区三区四区高清| 国产综合在线看| 亚洲狼人精品一区二区三区| 亚洲欧美欧美一区二区三区| 狼狼综合久久久久综合网| 99精品国产在热久久下载| 欧美在线视频免费| 欧美日韩精品免费在线观看视频| 欧美福利在线| 国产一级久久| 亚洲一级在线| 西瓜成人精品人成网站| 午夜精品一区二区三区电影天堂| 国产亚洲欧美aaaa| a91a精品视频在线观看| 久久视频一区二区|