303992: CF768A. Oath of the Night's Watch

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Oath of the Night's Watch

题意翻译

### 简要翻译 - 给定 $n$ 个非负整数 $a_{1 \ldots n}$。 - 你需要求出有多少个 $a_i$,满足:存在正整数 $j, k$,使得 $a_j < a_i$ 且 $a_k > a_i$。 - $1 \leqslant n \leqslant 10^5$;$\forall 1 \leqslant i \leqslant n$,有 $0 \leqslant a_i \leqslant 10^9$。 ### 题目描述 “长夜将至,我从今开始守望,至死方休。我将不娶妻,不封地,不生子。我将不戴宝冠,不争荣宠。我将尽忠职守,生死于斯。我是黑暗中的利剑,长城上的守卫,抵御寒冷的烈焰,破晓时分的光线,唤醒眠者的号角,守护王国的坚盾。我将生命与荣耀献给守夜人,今夜如此,夜夜皆然。”——《守夜人誓言》 琼恩·雪诺的守夜开始了。他被派去守护管家。 这次他需要守护 $n$ 个管家。每个管家都有他自己的力量值 $a$。琼恩喜欢守护一个管家,当且仅当存在至少一个力量值严格小于这个管家的管家,且存在至少一个力量值严格大于这个管家的管家。 你知道琼恩喜欢守护多少管家吗? ### 输入格式 共两行。 第一行:一个整数 $n$,表示琼恩需要守护的管家数量。 第二行:$n$ 个整数,第 $i$ 个数 $a_i$ 表示第 $i$ 个管家的力量值。 ### 输出格式 共一行,一个整数,表示琼恩喜欢守护的管家数量。 ### 说明/提示 #### 样例解释 - 样例 $1$ 解释:琼恩既不喜欢守护力量值为 $1$ 的管家,也不愿意守护力量值为 $5$ 的管家;因为没有任何一个管家的力量值小于 $1$,也没有任何一个管家的力量值大于 $5$。 - 样例 $2$ 解释:琼恩喜欢守护力量值为 $2$ 的管家,因为既有力量值小于 $2$ 的管家,也有力量值大于 $2$ 的管家。 #### 数据范围 - $1 \leqslant n \leqslant 10^5$。 - $\forall 1 \leqslant i \leqslant n,0 \leqslant a_i \leqslant 10^9$。

题目描述

"Night gathers, and now my watch begins. It shall not end until my death. I shall take no wife, hold no lands, father no children. I shall wear no crowns and win no glory. I shall live and die at my post. I am the sword in the darkness. I am the watcher on the walls. I am the shield that guards the realms of men. I pledge my life and honor to the Night's Watch, for this night and all the nights to come." — The Night's Watch oath. With that begins the watch of Jon Snow. He is assigned the task to support the stewards. This time he has $ n $ stewards with him whom he has to provide support. Each steward has his own strength. Jon Snow likes to support a steward only if there exists at least one steward who has strength strictly less than him and at least one steward who has strength strictly greater than him. Can you find how many stewards will Jon support?

输入输出格式

输入格式


First line consists of a single integer $ n $ ( $ 1<=n<=10^{5} $ ) — the number of stewards with Jon Snow. Second line consists of $ n $ space separated integers $ a_{1},a_{2},...,a_{n} $ ( $ 0<=a_{i}<=10^{9} $ ) representing the values assigned to the stewards.

输出格式


Output a single integer representing the number of stewards which Jon will feed.

输入输出样例

输入样例 #1

2
1 5

输出样例 #1

0

输入样例 #2

3
1 2 5

输出样例 #2

1

说明

In the first sample, Jon Snow cannot support steward with strength $ 1 $ because there is no steward with strength less than $ 1 $ and he cannot support steward with strength $ 5 $ because there is no steward with strength greater than $ 5 $ . In the second sample, Jon Snow can support steward with strength $ 2 $ because there are stewards with strength less than $ 2 $ and greater than $ 2 $ .

Input

题意翻译

### 简要翻译 - 给定 $n$ 个非负整数 $a_{1 \ldots n}$。 - 你需要求出有多少个 $a_i$,满足:存在正整数 $j, k$,使得 $a_j < a_i$ 且 $a_k > a_i$。 - $1 \leqslant n \leqslant 10^5$;$\forall 1 \leqslant i \leqslant n$,有 $0 \leqslant a_i \leqslant 10^9$。 ### 题目描述 “长夜将至,我从今开始守望,至死方休。我将不娶妻,不封地,不生子。我将不戴宝冠,不争荣宠。我将尽忠职守,生死于斯。我是黑暗中的利剑,长城上的守卫,抵御寒冷的烈焰,破晓时分的光线,唤醒眠者的号角,守护王国的坚盾。我将生命与荣耀献给守夜人,今夜如此,夜夜皆然。”——《守夜人誓言》 琼恩·雪诺的守夜开始了。他被派去守护管家。 这次他需要守护 $n$ 个管家。每个管家都有他自己的力量值 $a$。琼恩喜欢守护一个管家,当且仅当存在至少一个力量值严格小于这个管家的管家,且存在至少一个力量值严格大于这个管家的管家。 你知道琼恩喜欢守护多少管家吗? ### 输入格式 共两行。 第一行:一个整数 $n$,表示琼恩需要守护的管家数量。 第二行:$n$ 个整数,第 $i$ 个数 $a_i$ 表示第 $i$ 个管家的力量值。 ### 输出格式 共一行,一个整数,表示琼恩喜欢守护的管家数量。 ### 说明/提示 #### 样例解释 - 样例 $1$ 解释:琼恩既不喜欢守护力量值为 $1$ 的管家,也不愿意守护力量值为 $5$ 的管家;因为没有任何一个管家的力量值小于 $1$,也没有任何一个管家的力量值大于 $5$。 - 样例 $2$ 解释:琼恩喜欢守护力量值为 $2$ 的管家,因为既有力量值小于 $2$ 的管家,也有力量值大于 $2$ 的管家。 #### 数据范围 - $1 \leqslant n \leqslant 10^5$。 - $\forall 1 \leqslant i \leqslant n,0 \leqslant a_i \leqslant 10^9$。

加入题单

算法标签: