题目大意:
  给你一个数列,问数列中最小数的最近距离。

思路:
  直接模拟即可。

 #include<cstdio>
#include<cctype>
#include<algorithm>
inline int getint() {
register char ch;
while(!isdigit(ch=getchar()));
register int x=ch^'';
while(isdigit(ch=getchar())) x=(((x<<)+x)<<)+(ch^'');
return x;
}
const int inf=0x7fffffff;
int main() {
const int n=getint();
int ans;
for(register int i=,min=inf,pos;i<n;i++) {
const int x=getint();
if(x<min) {
min=x;
pos=i;
ans=inf;
} else if(x==min) {
ans=std::min(ans,i-pos);
pos=i;
}
}
printf("%d\n",ans);
return ;
}

[CF911A]Nearest Minimums的更多相关文章

  1. Educational Codeforces Round 35 A. Nearest Minimums【预处理】

    [题目链接]: Educational Codeforces Round 35 (Rated for Div. 2) A. Nearest Minimums time limit per test 2 ...

  2. 【Educational Codeforces Round 35 A】 Nearest Minimums

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 找出最小的数字的位置. 最近的肯定是相邻的某对. [代码] #include <bits/stdc++.h> using ...

  3. Educational Codeforces Round 35 (Rated for Div. 2)A,B,C,D

    A. Nearest Minimums time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  4. Educational Codeforces Round 35

    Nearest Minimums 相同的数里最小的数里的最小距离 Solution Two Cakes Solution Three Garlands 瞎比试 Solution Inversion C ...

  5. POJ 1330 Nearest Common Ancestors(Targin求LCA)

    传送门 Nearest Common Ancestors Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 26612   Ac ...

  6. [最近公共祖先] POJ 1330 Nearest Common Ancestors

    Nearest Common Ancestors Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 27316   Accept ...

  7. POJ 1330 Nearest Common Ancestors

    Nearest Common Ancestors Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 14698   Accept ...

  8. POJ1330 Nearest Common Ancestors

      Nearest Common Ancestors Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 24587   Acce ...

  9. Nearest number - 2_暴力&&bfs

    Description Input is the matrix A of N by N non-negative integers. A distance between two elements A ...

随机推荐

  1. webstorm中把style的内容隐藏,如何把style的内容展开?

    我们经常看到在webstorm中style的内容以...表示如下图所示,只有把光标移到上面时才会看到内容: 如何把上述的style的内容展开呢? 请按一下步骤操作: 第一步:File------> ...

  2. Join/remove server into/from windows domain PS script

    Join server into windows domain PS script $username = "ad-domain\admin" $Password = " ...

  3. C# new override

    A -> virtual Fun B : A -> override Fun C : B -> override Fun D : C -> new virtual Fun E ...

  4. linux网络编程系列-TCP/IP模型

    ### OSI:open system interconnection ### 开放系统互联网模型是由ISO国际标准化组织定义的网络分层模型,共七层 1. 物理层:物理定义了所有电子及物理设备的规范, ...

  5. Http/2 升级指南

    [转]http://www.syyong.com/architecture/http2.html HTTP/2(最初名为HTTP/2.0)是 WWW 使用的 HTTP 网络协议的主要版本. 它来自早先 ...

  6. [BZOJ1025] [SCOI2009]游戏 解题报告

    Description windy学会了一种游戏.对于1到N这N个数字,都有唯一且不同的1到N的数字与之对应.最开始windy把数字按顺序1,2,3,……,N写一排在纸上.然后再在这一排下面写上它们对 ...

  7. 【洛谷 P1667】 数列 (贪心)

    题目链接 对于一个区间\([x,y]\),设这个区间的总和为\(S\) 那么我们在前缀和(设为\(sum[i]\))的意义上考虑到原操作其实就是\(sum[x−1]+=S\) , \(sum[x]+S ...

  8. Django【进阶】FBV 和 CBV

    django中请求处理方式有2种:FBV 和 CBV 一.FBV FBV(function base views) 就是在视图里使用函数处理请求. 看代码: urls.py 1 2 3 4 5 6 7 ...

  9. c#使用selenium截图,操作dom元素

    using System; //添加selenium的引用 using OpenQA.Selenium.PhantomJS; using OpenQA.Selenium.Chrome; using O ...

  10. Python Standard Library

    Python Standard Library "We'd like to pretend that 'Fredrik' is a role, but even hundreds of vo ...