zoukankan      html  css  js  c++  java
  • 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 test
    2 seconds
    memory limit per test
    256 megabytes
    input
    standard input
    output
    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?

    Input

    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

    Output a single integer representing the number of stewards which Jon will feed.

    Examples
    input
    2
    1 5
    output
    0
    input
    3
    1 2 5
    output
    1
    Note

    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.

     

     思路:求出最大最小值后,扫一遍即可。

     1 #include <bits/stdc++.h>
     2 
     3 using namespace std;
     4 
     5 #define MP make_pair
     6 #define PB push_back
     7 typedef long long LL;
     8 typedef pair<int,int> PII;
     9 const double eps=1e-8;
    10 const double pi=acos(-1.0);
    11 const int K=1e6+7;
    12 const int mod=1e9+7;
    13 
    14 int n,mx,mi,ans,a[K];
    15 
    16 int main(void)
    17 {
    18     mi=1e9;
    19     cin>>n;
    20     for(int i=1;i<=n;i++)
    21         cin>>a[i],mx=max(mx,a[i]),mi=min(mi,a[i]);
    22     for(int i=1;i<=n;i++)
    23     if(a[i]>mi &&a[i]<mx)
    24     ans++;
    25     cout<<ans<<endl;
    26     return 0;
    27 }

     

  • 相关阅读:
    linux mono环境
    【百度杯】ctf夺旗大战,16万元奖励池等你拿
    【渗透技术】渗透测试技术分析_TomCat
    成功率“99%”!截止目前史上最强大电信诈骗术
    【sql注入】浅谈sql注入中的Post注入
    通过Weeman+Ettercap配合拿下路由器管理权限
    【sql注入教程】mysql注入直接getshell
    【云盘资料】Sql注入从菜鸟到高手系列教程
    【安全开发】浅谈JSP安全开发之XSS
    Python黑帽编程2.1 Python编程哲学
  • 原文地址:https://www.cnblogs.com/weeping/p/6425859.html
Copyright © 2011-2022 走看看