Minimize the cost of backing up ordered files to S3 by splitting batches.
Unlock detailed company stats for this questionUpgrade
Implement minStorageCost. Files 1..n must be backed up to S3 in order. For a batch of M files with X sensitive files, cost = M * X * encCost (only if X >= 1); a batch with 0 sensitive files costs flatCost. If a batch's size is divisible by 2, you may either store it whole or split it into two equal order-preserving halves and sum their costs. Splits preserve order: batch {1,4,2,6} can only split into {1,4} and {2,6}. Compute the minimum storage cost, modulo 1e9+7.
Example: batch {1,2,3,4}, sensitiveFiles = [1,3], encCost = 2, flatCost = 1 -> 6 (split fully to singles: sensitive cost 2 each, non-sensitive 1 each).
Constraints: 1 <= n <= 3 x 10^5; 1 <= encCost, flatCost <= 10^5; 1 <= K <= n.
Community answers
No answers contributed by the community yet.
Related courses

Course

Course
Course
