Codeforces 768A Oath of the Night's Watch

A. Oath of the Night's Watch
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

"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?

Input

First line consists of a single integer n (1 ≤ n ≤ 105) — the number of stewards with Jon Snow.

Second line consists of n space separated integers a1, a2, ..., an (0 ≤ ai ≤ 109) representing the values assigned to the stewards.

Output

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

Examples
input
2
1 5
output
0
input
3
1 2 5
output
1
Note

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.



解题思路:

直接用map计数,去掉前后,然后把剩下的数目个数相加



#include  
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define rsp(it,s) for(set::iterator it=s.begin();it!=s.end();it++)
const int inf_int = 2e9;
const long long inf_ll = 2e18;
#define inf_add 0x3f3f3f3f
#define MOD 1000000007
#define cinq  ios::sync_with_stdio(false)
#define pb push_back
#define mp make_pair
//#define fi first
#define se second
#define pi acos(-1.0)
#define pii pair
#define Lson L, mid, rt<<1
#define Rson mid+1, R, rt<<1|1
const int maxn=5e2+10;
using namespace std;
typedef  vector vi;
typedef  long long ll;
typedef  unsigned long long  ull; 
inline int read(){int ra,fh;char rx;rx=getchar(),ra=0,fh=1;
while((rx<'0'||rx>'9')&&rx!='-')rx=getchar();if(rx=='-')
fh=-1,rx=getchar();while(rx>='0'&&rx<='9')ra*=10,ra+=rx-48,
rx=getchar();return ra*fh;}
//#pragma comment(linker, "/STACK:102400000,102400000")
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;}
int dir[4][2]={{-1,0},{1,0},{0,-1},{0,1}};
const int N = 1e7+5;

typedef struct node{
	int x;
	int y;
	int step;
}NODE;
void initt()
{
	
}


int n;
string s; 
map a;
map::iterator it;
int t;
int main()
{
	
 	cinq;
 	cin >> n;
 	for(int i=0;i> t;
		a[t]++;	
	}
 	if(a.size()<=2)
 	{
 		cout <<0<se;
	}
	cout <






你可能感兴趣的:(codeforces,Codeforces刷题之旅,codeforces)