← All problemsSign in

A Good Problem

CodeChefRating 2791Open on judge ↗

Given an array A consisting of N integers - A1, A2....AN. You have to find the value of Σ MAX(i,j) * F(i,j) where 1 ≤ i . MAX(i,j) is defined as max(Ai,Ai+1...Aj). F(i,j) is defined as: - F(i,j) will be 1 if (Ai&Aj) = Aj or (Ai&Aj) = Ai - F(i,j) will be 0, otherwise. Here & denotes the bitwise AND operator. Input The first line of input will consist of integer N. The next line of in

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