Skip to content

Commit 2b1f9e8

Browse files
committed
Added 34A - Reconnaissance 2.cpp
1 parent 4ce8532 commit 2b1f9e8

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

34A - Reconnaissance 2.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
4+
// Code Written By: Vikash Patel
5+
6+
int main()
7+
{
8+
int n;
9+
cin>>n;
10+
int heights[n];
11+
for(int i=0;i<n;i++)
12+
{
13+
cin>>heights[i];
14+
}
15+
vector<pair<int,int>> ans;
16+
for(int j=0;j<n-1;j++)
17+
{
18+
int diff=abs(heights[j]-heights[j+1]);
19+
ans.push_back(make_pair(diff,j));
20+
}
21+
int lastfirstdiff=abs(heights[n-1]-heights[0]);
22+
sort(ans.begin(),ans.end());
23+
if(lastfirstdiff<ans[0].first)
24+
cout<<n<<" "<<1<<endl;
25+
else
26+
cout<<ans[0].second+1<<" "<<ans[0].second+2<<endl;
27+
}
28+
29+
30+
31+
32+
33+
34+

0 commit comments

Comments
 (0)