Codeforces 768A Oath of the Night's Watch 2017-02-21 22:13 39人阅读 评论(0) 收藏
2 seconds
256 megabytes
standard input
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?
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 a single integer representing the number of stewards which Jon will feed.
2
1 5
0
3
1 2 5
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.
——————————————————————————————————————
题目的意思是给出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) 收藏的更多相关文章
- 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 ... 
- 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 ... 
- 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 ... 
- 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 ... 
- 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 ... 
- 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 ... 
- 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 ... 
- 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 ... 
- Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals)
		Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals) 说一点东西: 昨天晚上$9:05$开始太不好了,我在学校学校$9:40$放 ... 
随机推荐
- 安全关闭MySQL
			想要安全关闭 mysqld 服务进程,建议按照下面的步骤来进行: 0.用具有SUPER.ALL等最高权限的账号连接MySQL,最好是用 unix socket 方式连接: 1.在5.0及以上版本,设置 ... 
- emacs之配置php
			php-setting.el (require 'php-mode) 以后丰富 
- CodeForces - 983B  XOR-pyramid(区间dp,异或)
			XOR-pyramid time limit per test 2 seconds memory limit per test 512 megabytes input standard input o ... 
- 【UVA】11825 Hackers' Crackdown(状压dp)
			题目 传送门:QWQ 分析 $ n<= 16 $ 显然是状压 然后搞一搞(靠着蓝书yy一下) 代码 #include <bits/stdc++.h> using namespace ... 
- yum安装cacti
			环境: centos 6.5 -x64 cacti-0.8.7e.tar.gz mysql yum安装即可 yum服务使用centos自带的就行.如果是红帽请自行解决yum.本文不赘述. **注意:同 ... 
- application/json 和 application/x-www-form-urlencoded的区别
			public static string HttpPost(string url, string body) { //ServicePointManager.ServerCertificateVali ... 
- [Python] numpy.Matrix
			import numpy as np np.matrix('1, 2; 3, 4') #1, 2 #3, 4 np.matrix([[1,2],[3,4]]) #1, 2 #3, 4 
- IPv4正则表达式匹配
			IP地址的长度为32位,分为4段,每段8位.用十进制数字表示,每段数字范围为0~255,段与段之间用英文句点“.”隔开.例如:某台计算机IP地址为111.22.33.4. 分析IP地址的组成特点:25 ... 
- ubuntu sudo apt-get update与sudo apt-get upgrade的作用及区别,以及python pip的安装
			在UBUNTU下,我们维护一个源列表,源列表里面都是一些网址信息,这每一条网址就是一个源,这个地址指向的数据标识着这台源服务器上有哪些软件可以安装使用.编辑源命令: sudo gedit /etc/a ... 
- 关于hibernate4.3版本之后org.hibernate.service.ServiceRegistryBuilder被弃用
			之前一直都是使用hibernate4.2.21的我,有一天突然没有使用本地的jar包而是让IDEA自动下载最新版本的hibernate5.2.2之后,发现有几个经常使用的方法报错了. -这真是让我惊了 ... 
