Skip to main content
Back to problems
Codeforces
Medium
Greedy
Arrays
Sorting
Summer sell-off

Choose the best item(s) to sell after applying a discount rule so the total revenue is maximized.

Acceptance 0%
Also Available On
Other platform versions and source mappings for the same problem.
Problem Statement

Summer sell-off

You are given a list of items, each with a starting price. During a summer sale, each item may be sold only at a price determined by the sale rule described in the original problem. Your task is to determine the maximum total money that can be collected.

A typical solution needs to carefully account for how the sale rule affects different items over time or across price ranges, then combine the contributions efficiently rather than simulating every possibility naively.

Goal

Compute the maximum achievable total revenue under the sale rule.

Notes

  • Think about how each item contributes to the final answer.
  • The best strategy is usually based on sorting or sweeping through changes in value.
  • Be careful with ties and boundary conditions.

Input Format

  • The first line contains an integer nn.
  • The next line contains nn integers describing the item values or prices.
  • Additional lines may describe the sale rule parameters, depending on the case.

Because the exact original statement is unavailable, treat the input as the standard contest format for this problem family and focus on the intended algorithmic idea.

Output Format

  • Print a single integer: the maximum total revenue obtainable under the rules.

Constraints

  • 1n21051 \le n \le 2 \cdot 10^5 is a typical contest-sized bound.
  • Values fit in 32-bit signed integers.
  • An O(nlogn)O(n \log n) solution is expected.
Examples
Sample cases returned by the problem API.

Example 1

Input

5
5 1 3 2 4

Output

15

Explanation

Illustrative example: if every item is eventually sold and the objective is the total sum after applying the sale rule, then the total is simply 5+1+3+2+4 = 15. This example is only a placeholder because the exact official statement is unavailable.

Premium problem context

Unlock deeper context for this problem

Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.