How to Learn You Score
면접 대비시간 제한1초메모리 제한512 MB
세 인덱스에 대한 질의가 그 세 값의 최솟값과 최댓값의 합을 돌려줄 때, 4n 이하의 질의로 n개의 숨은 값을 모두 알아낸다.
문제
Petya participates in such contest that the participants only learn results of judging their submissions after the end of the contest.
There are problems numbered from to in the contest. For each problem he has made a submission. After the contest he was very eager to learn his points and his place. But the results would only be published at the closing ceremony, which is a few hours away.
Petya decided to find out his result before that: to get his points for each problem from the jury, he would ask weird questions. Let Petya's points be for problems , respectively. Petya doesn't know these numbers and wants to find them out.
Petya chooses three distinct numbers of the problems and asks the jury to tell him the sum of the minimum and the maximum points he received for these three problems. Fortunately, the jury answers such queries. Formally, if he queries about , , , he gets .
Petya still doesn't know how to find out all his points. Help him find out , by making no more than queries to the jury.
힌트
In this sample, there are problems, and Petya got , , , , points for the problems. If he queries about problems , , , his minimum points among them is (for the -nd problem), and his maximum is (for the -rd problem). Thus, the jury will answer to that query.