아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Junior price robot

면접 대비

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

요약
오늘 가격이 맨 앞에 오는 일별 가격 수열이 주어질 때, 오늘 가격 이하인 가장 가까운 과거 가격을 찾아 그 날짜 차이를 출력하고, 그런 가격이 없으면 infinity를 출력한다.
난이도

보통10점 중 4점

유형
배열, 스택, 구현
정답자
아직 제출이 없습니다

문제

The idea behind your latest business adventure, BarGain Overview (BGO), is to collect the history of prices for a certain item that is available for sale on the web. The BarGain score of a particular day is defined as the number of days since the price was lower or equal to today's price. The worst BarGain score is thus 11, and if the price is strictly better than all previous prices ever recorded, then it is infinity. You want to report the BarGain score to your customers to help them identify a good buy.

입력

The first line of input contains a single integer 2≤n≤400,0002 \leq n \leq 400\\,000, the number of days for which you have collected price data for the item. On the second line of input follows nn space-separated integers p_1,p_2,…,p_np\_1, p\_2, \ldots, p\_{n}, where 0≤p_i≤2⋅1060 \leq p\_i \leq 2 \cdot 10^6 is the price of the item i−1i-1 days ago. Today's price is p_1p\_1.

출력

A line containing today's BarGain score.

예제2

  1. 예제 1

    입력
    6
    9 10 11 9 12 11
    
    예상 출력
    3
    
  2. 예제 2

    입력
    3
    1 2 3
    
    예상 출력
    infinity