Tap here to switch tabs
Problem
Submissions

Problem: Maximum Number of Upgradable Servers

Maximum Number of Upgradable Servers gives each data center's server count, upgrade cost, sale value, and funds. Return its maximum upgrades after selling any number of servers independently.

Statement

You are given four integer arrays count, upgrade, sell, and money, each of length nn, representing the properties of nn distinct data centers.

For the ithi^{ {th}} data center:

  • count[i] represents the initial number of servers available.

  • upgrade[i] represents the cost to upgrade one server.

  • sell[i] represents the amount of money gained from selling one server.

  • money[i] represents the initial amount of money available.

In each data center independently, you may sell any number of servers to gain additional money, and then use the total available money to upgrade as many of the remaining servers as possible. Each server can either be upgraded, sold, or left unmodified. Money gained in one data center cannot be transferred to another.

Return an integer array ans of length nn, where ans[i] represents the maximum number of servers that can be upgraded in the ithi^{ {th}} data center.

Constraints:

  • 1≤1 \leq count.length == upgrade.length == sell.length == money.length ≤105\leq 10^5

  • 1≤1 \leq count[i], upgrade[i], sell[i], money[i] ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Number of Upgradable Servers

Maximum Number of Upgradable Servers gives each data center's server count, upgrade cost, sale value, and funds. Return its maximum upgrades after selling any number of servers independently.

Statement

You are given four integer arrays count, upgrade, sell, and money, each of length nn, representing the properties of nn distinct data centers.

For the ithi^{ {th}} data center:

  • count[i] represents the initial number of servers available.

  • upgrade[i] represents the cost to upgrade one server.

  • sell[i] represents the amount of money gained from selling one server.

  • money[i] represents the initial amount of money available.

In each data center independently, you may sell any number of servers to gain additional money, and then use the total available money to upgrade as many of the remaining servers as possible. Each server can either be upgraded, sold, or left unmodified. Money gained in one data center cannot be transferred to another.

Return an integer array ans of length nn, where ans[i] represents the maximum number of servers that can be upgraded in the ithi^{ {th}} data center.

Constraints:

  • 1≤1 \leq count.length == upgrade.length == sell.length == money.length ≤105\leq 10^5

  • 1≤1 \leq count[i], upgrade[i], sell[i], money[i] ≤105\leq 10^5