← All problemsSign in

Subarray ORs

CodeChefRating 2424Open on judge ↗

Given an array $A$ of $N$ non-negative integers, we define $f(A)$ in the following way: - Consider all partitions of the array $A$ into continuous subarrays, $A[L_1, R_1], A[L_2, R_2], \ldots, A[L_K, R_K]$ (you can choose $K$), where - $1 \le L_i \le R_i \le N$ - $L_1 = 1$, $R_K = N$ - $R_i = L_{i - 1} + 1$ - The score of a partition is defined as $\sum_{i = 1}^{K} (A_{L_i} | A_{L_i +

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start