Becoming an influencer
You’ve been posting a lot of content on social media throughout the last several months. Now you’d like to analyze your most popular period. You’d like to know the maximum amount of views your content got during a period that doesn’t exceed a time interval of length
The first line of the input contains two integers
n(1 ≤ n ≤ ) - the number of content pieces posted and
t(1 ≤ t ≤ ) - the maximum time interval you’d like to consider.
nlines contain space-separated integers - the time posted and the views obtained from the post (1 ≤ ≤ ).
The program should print the maximum sum of views that are within a time period not exceeding
4 5 10 1000 12 1500 6 2000 1 1100
The last two - posted at times 1 and 6 would result in 2000 + 1100 views.
Time limit: 2 seconds
Memory limit: 512 MB
Output limit: 1 MB