AND PLUS OR
Time limit3sMemory limit1024 MB
Given an array of length 2^N, find indices i, j with A[i] + A[j] < A[i AND j] + A[i OR j], or report that none exist.
- Level
Medium7 of 10
- Topics
- Bit manipulation, Divide and conquer, Array, Math
- Solved
- No attempts yet
Problem
For two nonnegative integers , let denote their bitwise AND and their bitwise OR.
You are given an array of length consisting of nonnegative integers. Find a pair of indices such that , or state that no such pair exists. If more than one such pair exists, print any of them.
Input
The first line contains an integer .
The second line contains integers, the array given in order.
Output
If an answer exists, output two integers denoting the answer, separated by a space. must be in the range . Otherwise, output -1.