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, ...
随机推荐
- System Error:/usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found
System Error:/usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found 1.运行程序是,系统报错库文件libstdc++. ...
- 2018-2019-2 《网络对抗技术》Exp1 PC平台逆向破解 Week3 20165233
Exp1 PC平台逆向破解 实验内容 一.基础知识点 NOP, JNE, JE, JMP, CMP汇编指令的机器码 NOP指令即"空指令",执行到NOP指令时,CPU什么也不做,机 ...
- linux 使用随笔
目录:1,ab命令 一,ab命令 ab网站压力测试命令的参数.输出结果的中文注解 ab命令是Apache的Web服务器的性能测试工具,它可以测试安装Web服务器每秒种处理的HTTP请求. 来自: ht ...
- VB6 内存释放
VB在内存释放方面是这样的, 首先和其他任何语言一样,如果是在stack分配的空间的话,操作系统自动进行管理 比如下面的语句 dim a as string '当a 超出它的作用范围以后,就会被释放掉 ...
- MySQL 获取最后插入的ID LAST_INSERT_ID用法
LAST_INSERT_ID() 自动返回最后一个INSERT或 UPDATE 查询中 AUTO_INCREMENT列设置的第一个表发生的值. MySQL的LAST_INSERT_ID的注意事项: 第 ...
- Spring boot 配置文件 使用占位符号
配置文件占位符 1:使用随机数 ${random.value}.${random.int}.${random.long} ${random.)}.${random.,]} 2: 占位符获取之前配置的值 ...
- Linux SWAP 交换分区配置说明(转)
一.SWAP 说明 1.1 SWAP 概述 当系统的物理内存不够用的时候,就需要将物理内存中的一部分空间释放出来,以供当前运行的程序使用.那些被释放的空间可能来自一些很长时间没有什么操作的程序,这些被 ...
- jsfl 巧用获取jsfl绝对路径,导入配置文件,注意配置文件无法改变舞台宽高
//获取jsfl下的AS3.xml配置文件的路径 var jsflURL_arr=fl.scriptURI.split("/"); jsflURL_arr.splice(jsflU ...
- as3 对于加载进来多层swf缩放操作
//swf实际尺寸 var oldWidth:Number = frameLder.contentLoaderInfo.content.width; var oldHeight:Number = fr ...
- HTTP状态码 解析
原文地址:HTTP状态码:400500错误代码(个人总结)作者:lining2008net 一些常见的状态码为: 200-服务器成功返回网页 404-请求的网页不存在 503-服务不可用 详细分解: ...