Procesor

시간 제한1초메모리 제한2048 MB

요약
비교 질의로만 확인할 수 있는 숨은 배열에서 비교 결과를 출력하거나, 가능할 때 가장 작은 원소를 찾아 제거하는 문제다.
난이도

쉬움10점 중 2점

유형
구현
정답자
아직 제출이 없습니다

문제

Initially, Fran has an empty array aa. Fran processes nn queries of the form xx — he appends xx elements to the end of aa. After each query, Fran wants to determine the smallest element in the array aa, and once he identifies it, he removes it from the array without altering the indices of the other elements.

Your task is to determine the smallest element of the array for each query by asking questions.

힌트

Explanation of the Sample Case:

The final array is of the form 3,2,4,1,53, 2, 4, 1, 5.

The first query outputs 11 because a_1>a_2a\_1 > a\_2.

The second query outputs 00 because a_1<a_3a\_1 < a\_3.

The third query outputs 00 because a_2<a_3a\_2 < a\_3.

After this, it can be determined that a_2a\_2 is the smallest current element, so the output is ! 22. The interaction continues with the subsequent queries.

예제1

  1. 예제 1

    입력
    3
    3
    
    1
    
    0
    
    0
    
    1
    
    1
    
    1
    
    0
    
    
    예상 출력
    
    
    ? 1 2
    
    ? 1 3
    
    ? 2 3
    
    ! 2
    
    ? 1 4
    
    ! 4
    
    ? 1 5
    
    ! 1