← CSES Better

Table Sum

INOI · 2012 · Indian National Olympiad in Informatics · INOI1202

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 · cyclic · sliding-window

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

cyclic table

Rotate one row against a fixed row

For each cyclic shift of the second row, the table score is the maximum column sum. Output one score for every shift.

State table
Rotation kColumn sumsOutput
k = 1..NA[i] + B[(i+k-1) mod N]max column sum for this k
all N rotationsone score per rotationoutput all N scores
  1. 1

    Form each rotation

    The fixed first row is paired with each of the N cyclic rotations of the second row.
  2. 2

    Score that table

    For one rotation, add the two values in each column and take the largest column sum.
  3. 3

    Report all rotations

    Output the score for every rotation in its prescribed order; do not maximize across rotations.
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.