Knights of the Frozen Throne is a famous online game developed and published by ICPC Entertainment, Inc. A single server called Zeus Super Computer (ZSC) handles all requests from all players of the
Knights of the Frozen Throne is a famous online game developed and published by ICPC Entertainment, Inc. A single server called Zeus Super Computer (ZSC) handles all requests from all players of the game. Originally, all players’ data is stored in ZSC’s memory so that the server can respond to a request without querying the database. However, this design hardly scales as the game becomes more and more popula As a great engineer in ICPC Entertainment, Tom wants to help the company save costs by using an awesome database with a very large capacity. After some investigation, Tom discovers the behavior patterns of all players, and he can accurately predict when a player will send a request. Now it’s time to deploy his optimization design: time-based caching. To introduce the time-based caching policy, instead of holding all players’ data in memory all the time, a player’s data is retained in memory only for a while, and ZSC will drop this player’s data if he doesn’t send any request for some time. Specifically, when the request from one player comes, if the player’s data is not in memory, ZSC loads his data into memory and records the last request time of the player; if the player’s data is already in memory, ZSC responds to this request immediately, then updates the last request time of the player. Also, ZSC would drop a player’s data from memory if X seconds (X is a positive integer parameter to be determined) have elapsed since his last request. In particular, if a request is sent exactly X seconds after the player’s last request time, ZSC does have to load the player’s data into memory. Initially, ZSC’s memory is empty. Tom wants you to help him determine the best positive integer X such that the total cost is minimized. As for the cost of CPU and memory, it costs a dollars for ZSC to hold one player’s data in memory for one second. ZSC’s CPU is pretty powerful,and it costs i⋅bii cdot b_ii⋅bi if i players' data is loaded in one second.