TouchStone
  Please Login
Login Sign Up
 Homepage  Problem Set  Examinations  Submissions  Discussions  Statistics
  • Home
  • Problem Set
  • P4866
  • Problem
  • P4866和谐数
    Limits : Time Limit : - MS   Memory Limit : - KB
    Judgment Tips : 1s,128m
    Description

    一个由 \(n\) 个整数构成数列 \(A_1,A_2,...,A_n\)
    对于第 \(i\) 个数字 \(A_i\):
    \(i\) 左边比 \(A_i\) 大的数字有 \(x\) 个,
    \(i\) 右边比 \(A_i\) 大的数字有 \(y\) 个,
    如果 \(max(x,y)>2*min(x,y)\) ,说明第 \(i\) 个数字是不和谐的。

    现在请你找出数列中总共有多少个不和谐的数字。

    Input Format

    第一行,一个整数 \(n\)
    接下来 \(n\) 行,每行一个整数,依次表示 \(A_1,A_2,...,A_n\)

    Output Format

    一个整数,表示不和谐的数字的个数。

    Sample Input 1

    7
    34
    6
    23
    0
    5
    99
    2

    Sample Output 1

    3

    Sample Input 2

    9
    1 2 3 1 1 2 3 2 2

    Sample Output 2

    4

    Hint

    对于40%的数据:1<=n<=1,000
    对于100%的数据:
    1<=n<=100,000
    0<=Ai<=1,000,000,000