#P3353. 在你窗外闪耀的星星
在你窗外闪耀的星星
Description
Now here is the problem: Think of the sky as a number line. On this number line there are many stars, each with a position and a brightness . Multiple stars may share the same position. The range a window can see is given by a parameter , and the stars we see also include those on the window’s boundaries. Find the maximum possible sum of brightness of the stars visible after adjusting the position of the window.
Input Format
One line with , the number of stars and the width of the window.
Each of the next lines contains and , the coordinate and brightness of a star.
Output Format
One number, the maximum total brightness of the visible stars.
6 3
1 2
2 4
3 8
4 4
5 2
1000 1
16
Hint
Sample explanation:

Constraints:
- For of the testdata, (no boundary).
- For of the testdata, .
- For of the testdata, , , , .
- Except for the case , is an odd integer .
Translated by ChatGPT 5
京公网安备 11011102002149号