abccccc123's blog

By abccccc123, history, 7 days ago, In English,

https://codeforces.com/contest/964/problem/B Can someone explain me how should I solve this problem I dont realy understand what should I do.. I aleready read the editorial but stil cant understand.

"Also, each minute Vasya's bank account receives C·k, where k is the amount of received but unread messages.

Vasya's messages are very important to him, and because of that he wants to have all messages read after T minutes." I dont know what that means.

 
 
 
 
  • Vote: I like it
  • -2
  • Vote: I do not like it

»
7 days ago, # |
  Vote: I like it 0 Vote: I do not like it

Take a message arriving at the minute i. For every minute that you don't read it, it's cost goes down by b. But since it is unread, c$ gets deposited in your account for that message.

So we can say that if b >= c, then we have to read the message the minute it is received as delaying it any further would effectively drain money from our account.
Else delay reading the message as much as possible, ie, till the last second to get the maximum profit.

Code

  • »
    »
    6 days ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    Ok thanks. One more question why c — b? Edit: Ohh nvm I understand now. Thanks again!

    • »
      »
      »
      6 days ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Let's say you delay a message by one minute. Its cost reduces by b. But since the number of unread messages increases by 1, our balance increases by c. So for every minute stalled, the effective amount deposited is c-b