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, ...
随机推荐
- JS监听浏览器事件
Onunload与Onbeforeunload Onunload,onbeforeunload都是在刷新或关闭时调用,可以在<script>脚本中通过window.onunload来指定或 ...
- 如何提取一个转录本的3'UTR区域的序列
庐州月光 如何提取一个转录本的3'UTR区域的序列 在做microRNA 和 mRNA 相互作用预测的时候,大家都知道microRNA 作用的靶点是位于mRNA 的3'UTR取,所以只需要提取mRNA ...
- Xshell图形界面启动
https://blog.csdn.net/qq_27843481/article/details/50539797 增加内存:https://jingyan.baidu.com/article/4d ...
- NLP—WordNet——词与词之间的最小距离
WordNet,是由Princeton 大学的心理学家,语言学家和计算机工程师联合设计的一种基于认知语言学的英语词典.它不是光把单词以字母顺序排列,而且按照单词的意义组成一个“单词的网络”.我们这次的 ...
- 可视化库-seaborn-布局风格设置(第五天)
1. sns.set_style() 进行风格设置, sns.set() 进行设置的重置, 五种风格 # 1.darkgrid# 2.whitegrid# 3.dark# 4.white# 5 tic ...
- js中怎么写自执行函数
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...
- Numpy统计
Numpy统计 axis=None 是统计函数的标配参数,默认不输入此参数则为对数组每一个元素进行计算,设定轴则对此轴上元素进行计算 1:常用统计函数 .sum(a,axis=None):数组a求和运 ...
- 问题解决Android studio遇到 java.lang.OutOfMemoryError: GC app:transformClassesWithDexForDebug解决方法 以及gradle优化
http://blog.csdn.net/xiaoxing0828/article/details/52242090
- Hive—学习笔记(一)
主要内容: 1.Hive的基本工能机制和概念 2.hive的安装和基本使用 3.HQL 4.hive的脚本化运行使用方式 5.hive的基本语法--建表语法 6.hive的基本语法--内部表和外部表. ...
- Java的反射和代理以及注解
最近接触到java的反射和代理(接触的有点迟了...),还是有必要总结下 1. Java的反射 有的时候我们需要在程序运行的时候获取类.方法等信息用于动态运行,这个时候反射就能够帮我们找到类.方法.成 ...