1. 程式人生 > >HDU 5360 Hiking (貪心+優先佇列)

HDU 5360 Hiking (貪心+優先佇列)

There are n soda conveniently labeled by 1,2,,n. beta, their best friends, wants to invite some soda to go hiking. The i-th soda will go hiking if the total number of soda that go hiking except him is no less than li and no larger than ri. beta will follow the rules below to invite soda one by one:
1. he selects a soda not invited before;
2. he tells soda the number of soda who agree to go hiking by now;
3. soda will agree or disagree according to the number he hears.

Note: beta will always tell the truth and soda will agree if and only if the number he hears is no less than l
i
 and no larger than ri, otherwise he will disagree. Once soda agrees to go hiking he will not regret even if the final total number fails to meet some soda's will.

Help beta design an invitation order that the number of soda who agree to go hiking is maximum.

相關推薦

HDU 5360 Hiking 貪心+優先佇列

There are n soda conveniently labeled by 1,2,…,n. beta, their best friends, wants to invite some soda to go hiking. The i-th soda will go hiking if the

D. Fedor and coupons貪心+優先佇列

Note In the first example if we take the first two coupons then all the products with ids in range [40, 70] can be bought with both coupons. There are 

bzoj1029: [JSOI2007]建築搶修貪心 + 優先佇列

原題連結 題目描述:小剛在玩JSOI提供的一個稱之為“建築搶修”的電腦遊戲:經過了一場激烈的戰鬥,T部落消滅了所有z部落的入侵者。但是T部落的基地裡已經有N個建築設施受到了嚴重的損傷,如果不盡快修復的話,這些建築設施將會完全毀壞。現在的情況是:T部落基地裡只有一個修理工人,雖然他能瞬間到達任何一個建築,但是

poj 3614 抹防晒霜的牛貪心 + 優先佇列

題意: 有c只牛,l個瓶子。 每隻牛有一個防晒區間,minSpf 和 maxSpf,在這個區間內才能保持良好的防晒姿勢。 現在每個瓶子裡的防晒值是spf,然後每個瓶子能搞cover只牛。 問最多能夠讓幾頭牛保持良好的防晒姿勢。 解析: 莫名其妙就搞了一個早上。 另一道dp

Sunscreen 貪心+優先佇列

To avoid unsightly burns while tanning, each of the C (1 ≤ C ≤ 2500) cows must cover her hide with sunscreen when they're at the beach. C

POJ 3253貪心 + 優先佇列

《挑戰程式設計競賽》,初級篇–樹 // 貪心 + 優先佇列(大根堆,小根堆) #include <iostream> #include <cstdio> #include <queue> using namespace

合併果子貪心+優先佇列

現在有n堆果子,第i堆有ai個果子。現在要把這些果子合併成一堆,每次合併的代價是兩堆果子的總果子數。求合併所有果子的最小代價。 Input 第一行包含一個整數T(T<=50),表示資料組數。 每組資料第一行包含一個整數n(2<=n<=1000),表示果子的堆數。 第二行包含n個正整數ai(

Hello 2018 D. Too Easy Problems貪心+優先佇列

You are preparing for an exam on scheduling theory. The exam will last for exactly T milliseconds and will consist of n problems. You can either solve p

POJ1456Supermarket貪心+優先佇列

Supermarket Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 9103 Accepted: 3891 Description A supermarket has a set Prod

HDU 5360 Hiking優先隊列

maximum iss tle sta hit height oat spl play Hiking Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Other

HDU 6438 Buy and Resell貪心+優先佇列+set

Description 有nnn個城市,第iii個城市商品價格為aia_iai​,從111城市出發依次經過這nnn個城市到達nnn城市,在每個城市可以把手頭商品出售也可以至多買一個商品,問最大收益以及在

【51Nod - 1163】最高的獎勵 貪心+優先佇列 或 妙用並查集

題幹: 有N個任務,每個任務有一個最晚結束時間以及一個對應的獎勵。在結束時間之前完成該任務,就可以獲得對應的獎勵。完成每一個任務所需的時間都是1個單位時間。有時候完成所有任務是不可能的,因為時間上可能會有衝突,這需要你來取捨。求能夠獲得的最高獎勵。 Input 第1行:一個數N,表示

【Codeforces-140C】New Year Snowmen貪心+優先佇列、二分

As meticulous Gerald sets the table and caring Alexander sends the postcards, Sergey makes snowmen. Each showman should consist of three snowballs:

1163】最高的獎勵 貪心+優先佇列 或 妙用並查集

題幹: 有N個任務,每個任務有一個最晚結束時間以及一個對應的獎勵。在結束時間之前完成該任務,就可以獲得對應的獎勵。完成每一個任務所需的時間都是1個單位時間。有時候完成所有任務是不可能的,因為時間上可能

釣魚貪心+優先佇列+過載運算子

釣魚 題目描述: 話說發源於小朋友精心設計的遊戲被電腦組的童鞋們藐殺之後非常不爽,為了表示安慰和鼓勵,VIP999決定請他吃一次“年年大豐收”,為了表示誠意,他還決定親自去釣魚,但是,因為還要準備2

poj 1456 Supermarket貪心+並查集,貪心+優先佇列

Supermarket Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 7677 Accepted: 3252 Description A supermarket has a set Prod o

hdu 2822BFS+優先佇列

Prairie dog comes again! Someday one little prairie dog Tim wants to visit one of his friends on the farmland, but he is as lazy as his friend (who require

【POJ】2786-Keep the Customer Satisfied貪心 + 優先佇列,姿勢不對就要跪

按照截止日期排序,之後一個一個遍歷,記錄當前時間,如果當前時間大於截止時間,那麼從選過的任務裡刪除一個花費最大的任務 優先佇列維護 14038525 2786 Accepted 11168K 1016MS C++ 905B 2015-04-02 12:22:16 #inc

貪心】CODE[VS] 1063 NOIP2004普及組-合併果子 刷題記錄模擬+優先佇列

日常水題 貪心策略:每次找代價最小的兩對合並,用小根堆來維護,每次合併之後將當前合併結果重新推入佇列,直到合併完成(n-1次) 程式碼如下 #include <cstdio>

hdu 1180 詭異的樓梯bfs+優先佇列

詭異的電梯,實在詭異!!! 分析到詭異的地方時,把我都搞迷了! 看你別人的程式碼!才知道這樣分析!!! 這題關鍵判斷電梯的方向!!!人可以為了減少時間停在原地不動等電梯改變方向!!! #include<stdio.h> #include<string.h