report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
Buttons game - FlandreOJ: Flandre Online Judge

Buttons game

Time limit: 1500 ms
Memory limit: 256 MB
You are playing a game with $n$ buttons. You will have $q$ turns, and in each turn, you can press one button. When you press the $i$-th button, you earn $s_i$ points. Additionally, the first time you press the $i$-th button, you also receive a bonus of $e_i$ points. Find a strategy to press the buttons to maximize your total score. ### Input - The first line contains two integers $n, q$. - The next $n$ lines, each containing two integers $e_i, s_i$. ### Output - Print an integer representing the maximum achievable score. ### Constraints - $1 \le n \le 10^6$. - $1 \le q \le 10^9$. - $1 \le s_i, e_i \le 10^6$. ### Sample Input: ``` 3 6 1 3 2 2 4 3 ``` Output: ``` 24 ```
Sorting
Points Sorting
Brewing potion
Smallest possible
Distance minimization
Segment
Cucumber
Maximum value arrangement
Buttons game
Building fence
Balance
Topic
Sorting
Greedy
Rating 1100
Solution (1) Solution