https://codeforces.com/contest/911

A

模拟

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 #define lson l,mid,rt<<1
 4 #define rson mid+1,r,rt<<1|1
 5 #define IT set<ll>::iterator
 6 #define sqr(x) ((x)*(x))
 7 #define pb push_back
 8 #define eb emplace_back
 9 #define maxn 5000005
10 #define eps 1e-8
11 #define pi acos(-1.0)
12 #define rep(k,i,j) for(int k=i;k<j;k++)
13 typedef long long ll;
14 typedef pair<int,int> pii;
15 typedef pair<ll,ll>pll;
16 typedef pair<ll,int> pli;
17 typedef pair<pair<int,string>,pii> ppp;
18 typedef unsigned long long ull;
19 const long long MOD=998244353;
20 const double oula=0.57721566490153286060651209;
21 using namespace std;
22 
23 int a[100005];
24 
25 
26 int main(){
27     std::ios::sync_with_stdio(false);
28     int n;
29     cin>>n;
30     int x=0x3f3f3f3f;
31     for(int i=1;i<=n;i++){
32         cin>>a[i];
33         x=min(x,a[i]);
34     }
35     int Min=0x3f3f3f3f;
36     int pre=-1;
37     for(int i=1;i<=n;i++){
38         if(a[i]==x){
39             if(pre==-1) pre=i;
40             else Min=min(Min,i-pre),pre=i;
41         }
42     }
43     cout<<Min<<endl;
44 }
View Code

相关文章:

  • 2021-09-25
  • 2021-07-11
  • 2022-03-02
  • 2022-01-01
  • 2021-05-17
  • 2022-02-02
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-25
  • 2021-12-23
  • 2021-05-17
相关资源
相似解决方案