Skip to main content
Back to problems
Codeforces
Easy
Math
Simulation
Amazon
Line to Cashier

Given the number of people in several cashiers' lines, find the earliest time when all customers can be processed after choosing one line strategy.

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

Problem

You are given several cashier queues. Each queue has a certain number of people waiting, and each cashier serves one person per unit of time.

You need to determine the minimum time needed to finish serving everyone if you can choose a single cashier line to join and then wait through the process implied by the problem setup.

For practice, think about how the total workload and the best queue choice affect the final time.

Goal

Compute the earliest completion time according to the described cashier-line process.

Input Format

  • The first line contains an integer nn — the number of cashier lines.
  • The second line contains nn integers describing the initial number of people in each line.

Output Format

  • Print one integer: the minimum time required.

Constraints

  • 1n1051 \le n \le 10^5
  • Queue sizes are non-negative integers
  • Use 64-bit integers if needed
Examples
Sample cases returned by the problem API.

Example 1

Input

3
3 1 2

Output

1

Explanation

The smallest line already has 1 person, so the earliest completion time is determined by that best choice.

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.