Farmer John has opened a swimming pool for his cows, figuring it will help them relax and produce more milk.
To ensure safety, he hires NN cows as lifeguards, each of which has a shift that covers some contiguous interval of time during the day. For simplicity, the pool is open from time 00 until time 109109 on a daily basis, so each shift can be described by two integers, giving the time at which a cow starts and ends her shift. For example, a lifeguard starting at time t=4t=4 and ending at time t=7t=7 covers three units of time (note that the endpoints are "points" in time).
Unfortunately, Farmer John hired KK more lifeguards than he has the funds to support. Given that he must fire exactly KKlifeguards, what is the maximum amount of time that can still be covered by the shifts of the remaining lifeguards? An interval of time is covered if at least one lifeguard is present.
The first line of input contains NN and KK (K≤N≤100,000,1≤K≤100K≤N≤100,000,1≤K≤100). Each of the next NN lines describes a lifeguard in terms of two integers in the range 0…1090…109, giving the starting and ending point of a lifeguard's shift. All such endpoints are distinct. Shifts of different lifeguards might overlap.
Please write a single number, giving the maximum amount of time that can still be covered if Farmer John fires KK lifeguards.
3 2
1 8
7 15
2 14
12
以上就是關(guān)于【2018年1月USACO美國(guó)計(jì)算機(jī)奧賽白金級(jí)題1】的解答,如需了解學(xué)校/賽事/課程動(dòng)態(tài),可至翰林教育官網(wǎng)獲取更多信息。
往期文章閱讀推薦:
AMC/BPhO/UKChO…下半年20+賽事集中開(kāi)考!抓住競(jìng)賽"黃金備賽期"!
2027 USAAIO人工智能奧賽報(bào)名進(jìn)行中!Round 1新規(guī)出爐,2月開(kāi)賽如何備考?

? 2026. All Rights Reserved. 滬ICP備2023009024號(hào)-1