首页
Python
Java
前端
数据库
Linux
Chatgpt专题
开发者工具箱
5124专题
hdu 5124 lines【转化为区间和】
John has several lines. The lines are covered on the X axis. Let A is a point which is covered by the most lines. John wants to know how many lines cover A. Input The first line contains a single in
阅读更多...
5124 lines
· 题意: 给n条线段,求某点上最多覆盖多少条线段。 ·hdu上有题解: 1002 lines我们可以将一条线段[xi,yi]分为两个端点xi和(yi)+1,在xi时该点会新加入一条线段,同样的,在(yi)+1时该点会减少一条线段,因此对于2n个端点进行排序,令xi为价值1,yi为价值-1,问题转化成了最大区间和,因为1一定在-1之前,因此问题变成最大前缀和,我们寻找最大值就是答案,另外的,
阅读更多...