← CSES Better

Special Sums

INOI · 2015 · Indian National Olympiad in Informatics · INOI1501

Open official problem ↗
Ask AI

Open a hint-first prompt in a new AI chat. Grok may ask you to confirm before sending.

Open Claude Desktop

arrays · circular · prefix-sums

The organizer’s problem statement is available at the official source link.

circular segment

Represent each circular segment in a doubled array

The segment endpoints contribute a-values; interior positions contribute b-values, including wraparound.

circular start ia_i + sum of interior b_k + a_jwrap from N to 1
  1. 1

    Unwrap the circle

    Duplicate the circular arrays so wraparound intervals become linear ranges.
  2. 2

    Use prefix totals

    Use prefix sums for interior b-values and add the two endpoint a-values.
  3. 3

    Choose the best segment

    Check every valid start/end pair and retain the maximum special sum.
Tools
1
2
3
4
5
6
7
8
9
10
11
12
Draft saved locally
|12 lines, 156 chars

Run output

Run your code to see output.