| Task: | Lista |
| Sender: | Senpai |
| Submission time: | 2017-03-06 16:59:43 +0200 |
| Language: | C++ |
| Status: | COMPILE ERROR |
Compiler report
input/code.cpp: In function 'int main()':
input/code.cpp:14:5: error: 'i' was not declared in this scope
d=v[i].second;
^Code
# include <bits/stdc++.h>
using namespace std;
vector <pair<int,int>> v;
int n,x,e,minimi,d;
int main(){
cin>>n;
minimi=100001;
for(int i=1; i<=n; i++){
cin>>x;
v.push_back({x,i});
}
sort(v.begin(),v.end());
d=v[i].second;
for(int i=0; i<n-1; i++){
if(v[i].first!=v[i+1].first){
d=v[i+1].second;
continue;}
else{
e=n-v[i+1].second+d-1;
minimi=min(e,minimi);
}
}
cout<<minimi;
}