We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4ce8532 commit 2b1f9e8Copy full SHA for 2b1f9e8
34A - Reconnaissance 2.cpp
@@ -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