Codey and Crimes
https://www.hackerrank.com/contests/codenection-2023-preliminary-round-open-category/challenges/cn-c8
Last updated
https://www.hackerrank.com/contests/codenection-2023-preliminary-round-open-category/challenges/cn-c8
Last updated
One night, Codey found itself at a 7-11 convenience store, faced with the desire to purchase n
items. Each item took seconds to process, and they were priced at ringgit(s). It was a challenging time for Codey, and its funds were tight, barely enough to afford all n
items. Unfortunately, Codey made a regrettable decision that night: it chose to steal.
Here's what it did: For each second the cashier took to process one of their items, Codey managed to steal another item without paying for it. Its goal was to acquire all n
items and save as much money as possible.
Now, as Codey reflects on their actions, it wants to know the total amount it ultimately ended up paying that night. Can you help Codey recall the cost of its choices?
The first line contains an integer n
, where n
represents the number of items Codey purchased.
The following n
lines describe each item, where each of them contains two integers , which represents the time it takes to process item i
, and the price of item i
, respectively.
Output a single integer representing the total amount that Codey ultimately ended up paying at the end of the night.