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.


——————————————————————————————————————

题目的意思是给出n个数,输出不是最大也不是最小的数的个数

排序,找出最大数个数最小数个数,总数减去就好,注意都是一样的情况

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <string>
#include <set>
#include <map>
using namespace std; int a[100005];
int n; int main()
{
while(~scanf("%d",&n))
{
for(int i=0;i<n;i++)
scanf("%d",&a[i]); sort(a,a+n);
if(a[0]==a[n-1])
printf("0\n");
else
{
int cnt=2;
for(int i=1;i<n;i++)
{
if(a[i]==a[i-1])
cnt++;
else
break;
}
for(int i=n-2;i>0;i--)
{
if(a[i]==a[i+1])
cnt++;
else
break;
}
printf("%d\n",n-cnt);
} }
return 0;
}

Codeforces 768A Oath of the Night's Watch 2017-02-21 22:13 39人阅读 评论(0) 收藏的更多相关文章

  1. Codeforces 766D Mahmoud and a Dictionary 2017-02-21 14:03 107人阅读 评论(0) 收藏

    D. Mahmoud and a Dictionary time limit per test 4 seconds memory limit per test 256 megabytes input ...

  2. Codeforces 343D Water Tree 分类: Brush Mode 2014-10-05 14:38 98人阅读 评论(0) 收藏

    Mad scientist Mike has constructed a rooted tree, which consists of n vertices. Each vertex is a res ...

  3. codeforces 678C. Joty and Chocolate(容斥) 2016-10-15 21:49 122人阅读 评论(0) 收藏

    C. Joty and Chocolate time limit per test 1 second memory limit per test 256 megabytes input standar ...

  4. codeforces 702C Cellular Network 2016-10-15 18:19 104人阅读 评论(0) 收藏

    C. Cellular Network time limit per test 3 seconds memory limit per test 256 megabytes input standard ...

  5. Codeforces 632D Longest Subsequence 2016-09-28 21:29 37人阅读 评论(0) 收藏

    D. Longest Subsequence time limit per test 2 seconds memory limit per test 256 megabytes input stand ...

  6. Codeforces 706C Hard problem 2016-09-28 19:47 90人阅读 评论(0) 收藏

    C. Hard problem time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...

  7. Codeforces 766C Mahmoud and a Message 2017-02-21 13:57 62人阅读 评论(0) 收藏

    C. Mahmoud and a Message time limit per test 2 seconds memory limit per test 256 megabytes input sta ...

  8. 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 ...

  9. Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals)

    Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals) 说一点东西: 昨天晚上$9:05$开始太不好了,我在学校学校$9:40$放 ...

随机推荐

  1. Hadoop序列化机制及实例

    序列化 1.什么是序列化?将结构化对象转换成字节流以便于进行网络传输或写入持久存储的过程.2.什么是反序列化?将字节流转换为一系列结构化对象的过程.序列化用途: 1.作为一种持久化格式. 2.作为一种 ...

  2. 转转转---js正则表达exec与match的区别说明

    正则表达式对象有两个定义方式:: 1.第一种定义: new RegExp(pattern, attributes);如var reg = new RegExp("abc",&quo ...

  3. Java 8 Lambda表达式之方法引用 ::双冒号操作符

    双冒号运算符就是java中的方法引用,方法引用的格式是类名::方法名. 这里只是方法名,方法名的后面没有括号“()”.--------> 这样的式子并不代表一定会调用这个方法.这种式子一般是用作 ...

  4. RPM安装卸载软件

    1.安装 rpm -i 需要安装的包文件名 举例如下: rpm -i example.rpm 安装 example.rpm 包: rpm -iv example.rpm 安装 example.rpm ...

  5. [ML] CostFunction [Octave code]

    function J = computeCostMulti(X, y, theta) m = length(y); % number of training examples J = 0; for i ...

  6. tensorflow-eagerAPI

    调用该API可以不通过 tensorflow.Session.run()调用 定义的张量constant tensor,可以直接print # -*- coding: utf-8 -*- from _ ...

  7. typedef用法和与define的区别

    typedef用来声明一个别名,typedef后面的语法,是一个声明.本来笔者以为这里不会产生什么误解的,但结果却出乎意料,产生误解的人不在少数.罪魁祸首又是那些害人的教材.在这些教材中介绍typed ...

  8. 清华镜像站安装docker

    https://mirrors.tuna.tsinghua.edu.cn/help/docker-ce/

  9. Windows安装MySQL教程

    一.下载MySQL MySQL官网首页 --> Download --> Community --> 选择“ MySQL Community Server” 即:MySQL下载连接 ...

  10. 磁盘存储结构与文件恢复实验(FAT文件系统)

    实验地点:主楼A2-412 一.实验室名称:主楼实验室A2-412                  二.实验项目名称:磁盘存储结构与文件恢复实验 三.实验学时:6学时 四.实验原理: 在Debug环 ...