Save 25%Black Friday: 25% off all plans — use code BLACKFRIDAY2026 at checkout. Ends Monday, Dec 7.Claim the deal

You are optimizing query execution for a virtual data warehouse. There are n different types of queries available, each with a fixed execution time and profit. You can choose exactly one query type and run it repeatedly within a time limit of k minutes. Your goal is to select the query type that maximizes total profit.

The selected query type can be executed multiple times (as many as fit within k minutes). Each query type has a fixed execution time (in minutes) and a fixed profit per execution. If multiple query types yield the same maximum profit, select the one with the smallest index.

Return both the maximum profit achievable and the index of the optimal query type. If no query can be executed within the time limit, return [0, -1].

Test Cases
Input
Output
Expected