Logo
(追記) (追記ここまで)

14449번 - Balanced Photo 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB44831828473.008%

문제

Farmer John is arranging his N cows in a line to take a photo (1 ≤ N ≤ 100,000). The height of the ith cow in sequence is hi, and the heights of all cows are distinct.

As with all photographs of his cows, FJ wants this one to come out looking as nice as possible. He decides that cow i looks "unbalanced" if Li and Ri differ by more than factor of 2, where Li and Ri are the number of cows taller than i on her left and right, respectively. That is, i is unbalanced if the larger of Li and Ri is strictly more than twice the smaller of these two numbers. FJ is hoping that not too many of his cows are unbalanced.

Please help FJ compute the total number of unbalanced cows.

입력

The first line of input contains N. The next N lines contain h1…hN, each a nonnegative integer at most 1,000,000,000.

출력

Please output a count of the number of cows that are unbalanced.

제한

예제 입력 1

7
34
6
23
0
5
99
2

예제 출력 1

3

힌트

In this example, the cows of heights 34, 5, and 2 are unbalanced.

출처

Olympiad > USA Computing Olympiad > 2016-2017 Season > USACO 2017 January Contest > Gold 1번

  • 문제의 오타를 찾은 사람: orihehe
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /