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$放 ...
随机推荐
- 【linux】linux DD命令
Linux-dd命令详解 dd 是 Linux/UNIX 下的一个非常有用的命令,作用是用指定大小的块拷贝一个文件,并在拷贝的同时进行指定的转换. 例1:要把一张软盘的内容拷贝到另一张软盘上,利用/t ...
- Spring AOP 不同配置方式产生的冲突问题
Spring AOP的原理是 JDK 动态代理和CGLIB字节码增强技术,前者需要被代理类实现相应接口,也只有接口中的方法可以被JDK动态代理技术所处理:后者实际上是生成一个子类,来覆盖被代理类,那么 ...
- NPOI-Excel系列-1002.创建带有Document Summary Information和Summary Information的Excel文件
1. using NPOI.HSSF.UserModel; using NPOI.HPSF; using NPOI.POIFS.FileSystem; using Microsoft.VisualSt ...
- ASP.NET Web Pages
ylbtech-.Net-ASP.NET Web Pages: 1.返回顶部 2.返回顶部 3.返回顶部 4.返回顶部 5.返回顶部 6.返回顶部 7.返回顶部 8.返 ...
- HDU6128-Inverse of sum
参考这篇博客:https://blog.csdn.net/dormousenone/article/details/77340852 #include<bits/stdc++.h> usi ...
- 小程序本作用域下怎么调用全局js
本地wxml文件 <view>app版本:{{version}}</view> 本地js文件 var app; Page({data:{ }, onLoad:function( ...
- 由du,df 得出不同结果反应出的问题
最近遇到了因为某种异常情况导致某目录下日志暴增,在修复异常情况后,发现pm2 不能启动,查看日志发现原因为空间不足. 使用du -sh查看确实为空间不足.在rm -rf 删除之后,仍然不能启动.这时用 ...
- 4_bootstrap之栅格系统
4.栅格系统 4.1.简述栅格系统 为了方便在布局容器中进行网页的布局操作. BootStrap提供了一套专门用于响应式开发布局的栅格系统. 栅格系统将一行分为12列,通过设定元素占用的列数来 布局元 ...
- asp.net要验证的用户名和密码
FormsAuthentication.Authenticate()方法要验证的用户名和密码必须存储在Web.config文件内.如果要验证存储在“ASP.NET成员资格数据库”中的密码,则需要调用M ...
- 重新设定McAfee Agent的菜单语言
默认安装的McAfee Agent,语言会根据系统中的设置,自动选择了语言. 有时想更换语言,却又不想重装McAfee Agent (以前叫 ePO Agent) 其实可以直接运行下面的命令进行重新设 ...