HDU 4006: The kth great number
The kth great number
[email protected] Sycamore [email protected] 8/8/2017 #include<bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, k; while (cin >> n >> k) { char ch; int t; multiset<int>s; while (n--) {cin >> ch; if (ch == ‘I‘) { cin >> t; s.insert(t); if (s.size() > k)s.erase(s.begin()); } else cout <<*s.begin()<<endl ; } } return 0; }
HDU 4006: The kth great number
相關推薦
HDU 4006: The kth great number
cout show ace c++ out mil while -a tex The kth great number[email protected]/* */ Sycamore [email protected]/* */ 8/8/2017 #i
HDU 4006 The kth great number(優先佇列)
由於只有插入操作,所以不很複雜的資料結構,優先佇列就可以了,每次保持佇列中有k個元素,這樣取出的頭必然是第k大 程式碼: #include <cstdio> #include <cstring> #include <algorithm>
hdu 4006 The kth great number(優先佇列)
Problem Description Xiao Ming and Xiao Bao are playing a simple Numbers game. In a round Xiao Ming c
hdu 4006 The kth great number 很複雜的線段樹,至少對於我來說,但也學會了很多!!!!!!!!!!
這道題是網路預選賽上做的,當時就是超時,後來知道是線段樹,從時間複雜度來說用線段樹先是將所用的點記錄然後nlog的快排,之後查詢就是logn了,軟和不用線段樹,之後的查詢是On的複雜度,要是來一堆大資料那就必然超時了 廢話不多說了,先將記錄的所用點排序,在離散化,建樹,將資
The kth great number HDU 4006(第K大)
題面: Xiao Ming and Xiao Bao are playing a simple Numbers game. In a round Xiao Ming can choose to write down a number, or ask Xiao Bao what the kth g
The kth great number multiset應用(找第k大值)
for begin urn mes etc when ++ multi size The kth great number Xiao Ming and Xiao Bao are playing a simple Numbers game. In a round Xiao
HDOJ4006 The kth great number --優先佇列求第k大數
The kth great number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65768/65768 K (Java/Others) Total Submission(s): 7004 Acc
HDU4006 The kth great number————棧和佇列(優先佇列)
Xiao Ming and Xiao Bao are playing a simple Numbers game. In a round Xiao Ming can choose to write down a number, or ask Xiao Bao w
HDU 4891 The Great Pan (字符串處理)
scan ref return eof 意思 ng- length count con 題目鏈接:HDU 4891 The Great Pan 求一串字符有多少種不同的意思,當中關心‘{’,‘}’之間的‘|’。和‘$‘,‘$‘之間的空格,連續N個空&
hdu-1492 The number of divisors(約數) about Humble Numbers---因子數公式
AI tro -- Go hdu esp clu mat -s 題目鏈接: http://acm.hdu.edu.cn/showproblem.php?pid=1492 題目大意: 給出一個數,因子只有2 3 5 7,求這個數的因子個數 解題思路: 直接求出指數即可
HDU - 3006 The Number of set(狀態壓縮位運算)
memset scl 所有 targe oid print push out queue http://acm.hdu.edu.cn/showproblem.php?pid=3006 題意 給定n個集合,每個集合都是由大於等於1小於等於m的數字組成,m最大為14。問由給
HDU 3948-The Number of Palindromes-迴文自動機
題意: 給出一個字串,求其不相同迴文子串的個數 思路: 迴文自動機模板題,因為迴文自動機中每個新建的結點就表示一個迴文子串,各個結點都不相同 所以不同迴文子串個數就是迴文自動機中新增結點個數,直接輸出即可 程式碼: #include <bits/stdc
HDU 1492 The number of divisors(約數) about Humble Numbers
Problem Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 1
HDU 3591 The trouble of Xiaoqian(多重背包+全然背包)
給他 cas 維數 color cost 代碼 01背包 size code HDU 3591 The trouble of Xiaoqian(多重背包+全然背包) http://acm.hdu.edu.cn/showproblem.php?pid=3591 題意:
hdu 5381 The sum of gcd 2015多校聯合訓練賽#8莫隊算法
names 來看 efi nbsp span ems multipl script there The sum of gcd Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K
hdu 1679 The Unique MST (克魯斯卡爾)
plm () pst cati 卡爾 nts 相等 cat get The Unique MST Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 24152 Accepted:
hdu 4717 The Moving Points(三分)
fine names -- sqrt blank .cn class 題目 col 題目鏈接:hdu 4717 The Moving Points 題意: 在二維平面上有n個點,每個點給出移動的方向和速度。 問在某個時刻,這些點中最大距離最小是多少,輸出時刻和距離。 題解:
hdu 4901 The Romantic Hero 計數dp,位計算
height accep fin -a can stop ott from include The Romantic Hero Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 131072/131072
tomcat server 報錯之 More than the maximum allowed number of cookies
int str sock lar time color errors round pin More than the maximum allowed number of cookies EVERE: Error processing request java.lang.
hdu 3861 The King’s Problem trajan縮點+二分圖匹配
acm ant 二分 scanf title atan size pair city The King’s Problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768