768A Oath of the Night's Watch
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.
#include <iostream>
#include <algorithm>
using namespace std;
#define LL long long
const LL H=1e6+;
LL a[H];
int main()
{
int n;
cin >> n;
for(int i = ; i < n; i++)
{
cin >> a[i];
}
sort(a, a + n);
int ans = ;
if(n <= )
cout << << endl;
else {
for(int i = ; i < n-;i++)
{
if((a[i] > a[]) && (a[i] < a[n-]))
ans ++;
}
cout << ans << endl;
}
return ;
}
768A Oath of the Night's Watch的更多相关文章
- 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 768A Oath of the Night's Watch 2017-02-21 22:13 39人阅读 评论(0) 收藏
A. Oath of the Night's Watch time limit per test 2 seconds memory limit per test 256 megabytes input ...
- 【codeforces 768A】Oath of the Night's Watch
[题目链接]:http://codeforces.com/contest/768/problem/A [题意] 让你统计这样的数字x的个数; x要满足有严格比它小和严格比它大的数字; [题解] 排个序 ...
- 为什么要使用oath协议?
一.如何查看用户是否登录? 通过cookie和session来查看用户是否登录. 如果cookie对应的session中保存了用户登录信息,则判定用户已登录 Jsessionid,也就是tomcat自 ...
- Divide by Zero 2017 and Codeforces Round #399 (Div. 1 + Div. 2, combined) A. Oath of the Night's Watch
地址:http://codeforces.com/problemset/problem/768/A 题目: A. Oath of the Night's Watch time limit per te ...
- Portswigger web security academy:OAth authentication vulnerable
Portswigger web security academy:OAth authentication vulnerable 目录 Portswigger web security academy: ...
- OAth 2.0 的白话讲解
一.OAuth2.0是什么,主要做什么用的? 官方注解 简单说,OAuth 就是一种授权机制.数据的所有者告诉系统,同意授权第三方应用进入系统,获取这些数据.系统从而产生一个短期的进入令牌(token ...
- The Programmer's Oath程序员的誓言----鲍勃.马丁大叔(Bob Martin)
In order to defend and preserve the honor of the profession of computer programmers, I Promise that, ...
- The Programmer's Oath程序员的誓言----鲍勃·马丁大叔(Bob Martin)
In order to defend and preserve the honor of the profession of computer programmers, I Promise that, ...
随机推荐
- 编写一个函数,在页面上输出一个N行M列的表格,表格内容填充0~100的随机数字
function print(n,m){ document.write("<table>"); for(var i=0; i<n; i++){ ...
- String.Join() 方法 的用法
连接指定数组的元素或集合的成员,在每个元素或成员之间使用指定的分隔符.重载此成员.有关此成员的完整信息(包括语法.用法和示例),请单击重载列表中的相应名称 Join(String, IEnumerab ...
- ftps加密服务器
咱不废话,理论不提,直接上步骤,[linux下的ftps服务器系统搭建步骤如下,按此步骤,即可搭建ftps服务器系统] 1.[安装vsftpd] yum -y install vsftpd 2.[安装 ...
- 29. 在Linux上使用unzip解压以默认编码解压,中文文件名会出现乱码
解决办法: 下载p7zip-9.13-1.el5.rf.x86_64.rpm和p7zip-plugins-9.13-1.el5.rf.x86_64.rpm包 用以下方法安装后,使用7z x filen ...
- 1.Spring AOP (上)
转自:https://blog.csdn.net/yusheng8711/article/details/21622773 Spring有两大核心,IOC和AOP.IOC在java web项目中无时无 ...
- VBA 编写类
一.初识类 现在,请打开你的VBE,主菜单-插入-类模块. 插入了一个类模块,也就建立了一个类.类模块的名字就是类的名字.你现在看到的,她的名字叫“类1”,这是VBA按她姐妹排行给她取的的,是的,VB ...
- libcur+openssl的编译,使之支持SSL<转>
本机环境: Visual Studio 2010 . Windows 7 64 bit 1: 下载文件 1.1 libcurl: curl-7.49.1.zip 地址: https://curl.ha ...
- ztree参考
ztree一 ztree二 ztree三
- 通过http方式关闭和重启Jenkins
Jenkins关闭和重启实现方式. 1.关闭Jenkins 只需要在访问jenkins服务器的网址url地址后加上exit.例如我jenkins的地址http://localhost:8080/, ...
- ansible进阶小技巧--tags
用ansible写playbook的朋友可能会发现,当配置工作很多时,如果在中间过程出错了,修改后想重新执行,前面的一大堆步骤让人感觉很烦躁.虽然提供了“retry”文件,但是却只是根据host来判断 ...