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. java 静态方法上的泛型

    靜態方法上的泛型 泛型也可以僅定義在靜態方法上,舉例而言,在 定義與使用泛型 中自定義過支援泛型的ArrayList,如果現在想寫個asArrayList方法,可指定不定長度引數,將之轉換為Array ...

  2. usaco 2009 12 过路费

    最近学的图论,oj上的这道题卡了我一上午,写一下总结. 题目描述: 跟所有人一样,农夫约翰以着宁教我负天下牛,休教天下牛负我(原文:宁我负人,休教人负我)的伟大精神,日日夜夜苦思生财之道.为了发财,他 ...

  3. ubuntu16.04初始化配置

    允许root登录 sudo passwd root 启动网卡DHCP并配置DNS vi /etc/network/interfaces auto ens3 #auto lo iface ens3 in ...

  4. 读Understanding the Linux Kernel, 3rd Edition有感

    14.3.2.2. Avoiding request queue congestion Each request queue has a maximum number of allowed pendi ...

  5. django rest_framework 框架的使用03

    rest_framework的 数据解析器 首先需要知道前端发给后端的数据格式头有哪些: media_type = 'application/json' media_type = 'applicati ...

  6. python写exploit采集器

    前言: 根据天文地理与风水学,我掐指一算的看到了一篇不错的文章,文章里面写到整理exploit 我顿时心理想写一个exploit采集器,那么说时迟那时快.就开始写了 代码: 思路:http://exp ...

  7. 为什么重写equals后要重写hashCode

    equals和hashCode的关系 要搞清楚题目中的问题就必须搞明白equals方法和hashCode方法分别是什么,和诞生的原因,当搞明白了这一点其实题目就不算是个问题了,下面我们来探讨分别探讨一 ...

  8. 安装MySQL时出现黄色感叹号,提示3306已被占用

    windows系统如何查看现在某个端口的应用进程id呢,命令是: 1.netstat  -aon|findstr 3306 2.最后的那个数值就是进程id号,此时需要查看该id号对应的应用是哪一个,可 ...

  9. 读书笔记--大规模web服务开发技术

    总评        这本书是日本一个叫hatena的大型网站的CTO写的,通过hatena网站从小到大的演进来反应一个web系统从小到大过程中的各种系统和技术架构变迁,比较接地气.      书的内容 ...

  10. 解决CentOS内网机通过Windows下架设代理来访问网络

    新分配的CentOS运行在内网环境下,无法连接Internet,为了能够使用yum部署OpenVas工具,需要在内网下一台Windows主机架设代理,作代理服务器来令虚拟机上网. 代理服务器选择了CC ...