[CF911A]Nearest Minimums
题目大意:
给你一个数列,问数列中最小数的最近距离。
思路:
直接模拟即可。
#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的更多相关文章
- Educational Codeforces Round 35 A. Nearest Minimums【预处理】
[题目链接]: Educational Codeforces Round 35 (Rated for Div. 2) A. Nearest Minimums time limit per test 2 ...
- 【Educational Codeforces Round 35 A】 Nearest Minimums
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 找出最小的数字的位置. 最近的肯定是相邻的某对. [代码] #include <bits/stdc++.h> using ...
- 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 ...
- Educational Codeforces Round 35
Nearest Minimums 相同的数里最小的数里的最小距离 Solution Two Cakes Solution Three Garlands 瞎比试 Solution Inversion C ...
- POJ 1330 Nearest Common Ancestors(Targin求LCA)
传送门 Nearest Common Ancestors Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 26612 Ac ...
- [最近公共祖先] POJ 1330 Nearest Common Ancestors
Nearest Common Ancestors Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 27316 Accept ...
- POJ 1330 Nearest Common Ancestors
Nearest Common Ancestors Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 14698 Accept ...
- POJ1330 Nearest Common Ancestors
Nearest Common Ancestors Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 24587 Acce ...
- Nearest number - 2_暴力&&bfs
Description Input is the matrix A of N by N non-negative integers. A distance between two elements A ...
随机推荐
- bzoj 1110 [POI2007]砝码Odw 贪心+进制转化
[POI2007]砝码Odw Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 661 Solved: 366[Submit][Status][Disc ...
- linux 下查看网卡工作速率
[root@hadoop058 ~]# mii-tool eth0: negotiated 100baseTx-FD, link ok 100M linux 下查看网卡工作速率 Ethtool是用于查 ...
- sublime JSX Html 标签补全
Preferences -> Package Settings -> Emmet ->key bindings – user { "keys": ["t ...
- PostgreSQL(Linux)安装、启动、停止、重启
If we don't already have PostgreSQL installed, we must install it. $ sudo apt-get install postgresql ...
- MySQL中大于等于小于等于的写法
由于在mybatis框架的xml中<= , >=解析会出现问题,编译报错,所以需要转译 第一种写法: 原符号 < <= > >= & ' " 替换 ...
- 【BZOJ3624】【APIO2008】免费道路 [生成树][贪心]
免费道路 Time Limit: 2 Sec Memory Limit: 128 MB[Submit][Status][Discuss] Description Input Output Sampl ...
- 【CF1027D】Mouse Hunt(拓扑排序,环)
题意:给定n个房间,有一只老鼠可能从其中的任意一个出现, 在第i个房间设置捕鼠夹的代价是a[i],若老鼠当前在i号房间则下一秒会移动到b[i]号, 问一定能抓住老鼠的最小的总代价 n<=2e5, ...
- swift xcode设置 ,代码折叠,全局折叠 快捷键
在preference text editing 里面打开 function 折叠的项, 折叠方法快捷键: option+command +left/right 全局折叠快捷键: shift+opti ...
- Guava Cache相关
官方:http://ifeve.com/google-guava-cachesexplained/ 理解:https://segmentfault.com/a/1190000007300118 项目中 ...
- Oracle基础 11 约束 constraints
--主.外键约束 create table t( id int primary key); create table t1( id int references t(id)); 或者create ...