[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 ...
随机推荐
- wyh的物品~(二分)
链接:https://www.nowcoder.com/acm/contest/93/I来源:牛客网 题目描述 wyh学长现在手里有n个物品,这n个物品的重量和价值都告诉你,然后现在让你从中选取k个, ...
- 网络编程:connect函数
TCP客户用connect函数来建立与TCP服务器的连接: cpp #include<sys/socket.h> int connect(int sockfd, const struct ...
- commons
<!-- https://mvnrepository.com/artifact/commons-lang/commons-lang --> <dependency> <g ...
- [POJ2406&POJ1961]用KMP解决字符串的循环问题两例
翻阅了一下网上资料,发现大部分都说这题是找规律...或是说YY出的一个算法..不会证明... 然后就脑补了一下证明 ~ 结论:对于一个字符串S[1..N],如果N mod (N-next[N])=0 ...
- Oop分析方法
为了实现Oop,这个我已经在一个前端的js项目中实现了Oop,过后总结:对于js这种动态语言,可以在运行时动态组件对象的属性和方法这种,解释型的语言来讲,真的是OOP,如果不存在关系数据库,仅仅是从后 ...
- 为什么VS没有提供平win64程序编写项
最近在学习C++和MFC编程,突然有个疑问,为什么每次新建项目时,都只有win32 console application,从来没见过win64的选项,于是去网上查了查,下面是我找到的几个答案: 作者 ...
- ie6浏览器兼容性
1.ie6双倍边距bug 块状元素设置float(左浮动或有浮动),并且设置margin值之后,第一个浮动的元素其左侧margin值为正常的2倍,如图,可以看到第一个元素的左侧边距于其他元素两两之间的 ...
- mysql 表的类型
MySQL 数据表主要支持六种类型 ,分别是:BDB.HEAP.ISAM.MERGE.MYISAM.InnoBDB. 这六种又分为两类,一类是”事务安全型”(transaction-safe),包括B ...
- Python学习笔记 - day1 - 概述及安装
Python概述 Python是一种计算机程序设计语言.我们平时已经听说过很多种流行的编程语言,比如非常难学的C语言,非常流行的Java语言,适合网页编程的JavaScript语言等等. Python ...
- Python3安装cx_Oracle连接oracle数据库实操总结
弄清版本,最重要!!! 首先安装配置时,必须把握一个点,就是版本一致!包括:系统版本,python版本,oracle客户端的版本,cx_Oracle的版本,然后安装配置就容易了! 如果已经安装Pyth ...