Galactic Collegiate Programming Contest 題解

題目描述:
One hundred years from now, in 2117, the International Collegiate Programming Contest (of which the NCPC is a part) has expanded significantly and it is now the Galactic Collegiate Programming Contest (GCPC).
This year there are n teams in the contest. The teams are numbered 1,2,…,n, and your favorite team has number 1.

Like today, the score of a team is a pair of integers (a,b) where a is the number of solved problems and b is the total penalty of that team. When a team solves a problem there is some associated penalty (not necessarily calculated in the same way as in the NCPC – the precise details are not important in this problem). The total penalty of a team is the sum of the penalties for the solved problems of the team.

Consider two teams t1 and t2 whose scores are (a1,b1) and (a2,b2). The score of team t1 is better than that of t2 if either a1>a2, or if a1=a2 and b1<b2. The rank of a team is k+1 where k is the number of teams whose score is better.

You would like to follow the performance of your favorite team. Unfortunately, the organizers of GCPC do not provide a scoreboard. Instead, they send a message immediately whenever a team solves a problem.

Input
The first line of input contains two integers n and m, where 1≤n≤105 is the number of teams, and 1≤m≤105 is the number of events.

Then follow m lines that describe the events. Each line contains two integers t and p (1≤t≤n and 1≤p≤1000), meaning that team t has solved a problem with penalty p. The events are ordered by the time when they happen.

Output
Output m lines. On the i’th line, output the rank of your favorite team after the first i events have happened.

忆蚀、

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子茴恰,更是在濱河造成了極大的恐慌莽龟,老刑警劉巖琅翻,帶你破解...
    沈念sama閱讀 221,548評論 6 515
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件悴能,死亡現(xiàn)場離奇詭異携悯,居然都是意外死亡杂伟,警方通過查閱死者的電腦和手機(jī)移层,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,497評論 3 399
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來赫粥,“玉大人观话,你說我怎么就攤上這事≡狡剑” “怎么了频蛔?”我有些...
    開封第一講書人閱讀 167,990評論 0 360
  • 文/不壞的土叔 我叫張陵,是天一觀的道長秦叛。 經(jīng)常有香客問我帽驯,道長,這世上最難降的妖魔是什么书闸? 我笑而不...
    開封第一講書人閱讀 59,618評論 1 296
  • 正文 為了忘掉前任尼变,我火速辦了婚禮,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘嫌术。我一直安慰自己哀澈,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 68,618評論 6 397
  • 文/花漫 我一把揭開白布度气。 她就那樣靜靜地躺著割按,像睡著了一般。 火紅的嫁衣襯著肌膚如雪磷籍。 梳的紋絲不亂的頭發(fā)上适荣,一...
    開封第一講書人閱讀 52,246評論 1 308
  • 那天,我揣著相機(jī)與錄音院领,去河邊找鬼弛矛。 笑死,一個(gè)胖子當(dāng)著我的面吹牛比然,可吹牛的內(nèi)容都是我干的丈氓。 我是一名探鬼主播,決...
    沈念sama閱讀 40,819評論 3 421
  • 文/蒼蘭香墨 我猛地睜開眼强法,長吁一口氣:“原來是場噩夢啊……” “哼万俗!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起饮怯,我...
    開封第一講書人閱讀 39,725評論 0 276
  • 序言:老撾萬榮一對情侶失蹤闰歪,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后蓖墅,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體库倘,經(jīng)...
    沈念sama閱讀 46,268評論 1 320
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 38,356評論 3 340
  • 正文 我和宋清朗相戀三年置媳,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片公条。...
    茶點(diǎn)故事閱讀 40,488評論 1 352
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡拇囊,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出靶橱,到底是詐尸還是另有隱情寥袭,我是刑警寧澤,帶...
    沈念sama閱讀 36,181評論 5 350
  • 正文 年R本政府宣布肺蔚,位于F島的核電站持际,受9級特大地震影響址遇,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜膘掰,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,862評論 3 333
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧识埋,春花似錦凡伊、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,331評論 0 24
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至惠豺,卻和暖如春银还,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背洁墙。 一陣腳步聲響...
    開封第一講書人閱讀 33,445評論 1 272
  • 我被黑心中介騙來泰國打工蛹疯, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人扫俺。 一個(gè)月前我還...
    沈念sama閱讀 48,897評論 3 376
  • 正文 我出身青樓苍苞,卻偏偏與公主長得像,于是被迫代替她去往敵國和親狼纬。 傳聞我的和親對象是個(gè)殘疾皇子羹呵,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,500評論 2 359

推薦閱讀更多精彩內(nèi)容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi閱讀 7,345評論 0 10
  • **2014真題Directions:Read the following text. Choose the be...
    又是夜半驚坐起閱讀 9,569評論 0 23
  • 午:清湯麻辣青菜、肥牛疗琉、鴨胸 活動:瑜伽課一節(jié)冈欢,整理點(diǎn)文字資料 感受:心情焦慮,對未知充滿恐懼盈简,最中放棄點(diǎn)個(gè)炸雞的...
    大公主要叛逆閱讀 187評論 0 0
  • 在生活中,你若是遇到誰帶著得意或者鄙視臼勉,脫口而出類似以下句子的人邻吭,你最好趁早避開他們。宴霸。囱晴。。 |“你連這都不知道啊...
    夜貓子譚娟閱讀 392評論 0 0
  • 一瓢谢、關(guān)于貪婪 作為天主教“七宗罪”和佛教“五戒”之一畸写,維基百科給出的解釋是貪婪指一種攫取遠(yuǎn)超過自身需求的金錢、物質(zhì)...
    空空曉語閱讀 364評論 0 0