The XYZ class has N students numbered from 1 to N. Each student is represented by two positive integers a_i and b_i, where b_i represents the skill level of the i student. There are 60 subjects taught in the class. Student i is good at subject j if the j^{th} bit of the binary representation of a_i is 1, otherwise it is 0.
Student i feels superior to student j if and only if there is at least one subject that i is good at but j is not. In other words, when a_i and a_j are represented in binary form, there exists a position k where the k^{th} bit of a_i is 1 and the k^{th} bit of a_j is 0. Two students may both feel superior to another student.
The homeroom teacher wants to select a group of students to participate in a competition. The group is formed if there are at least 2 members and no member in the group feels superior to all other members. The teacher wants to select the group with the highest total skill level of the students. Help the teacher find the maximum total skill level. If it is not possible to form a group, output 0.
Dữ liệu vào Sao chép |
4 3 2 3 6 2 8 5 10 |
Dữ liệu ra Sao chép |
15 |