-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path34A - Reconnaissance 2.cpp
More file actions
61 lines (56 loc) · 978 Bytes
/
34A - Reconnaissance 2.cpp
File metadata and controls
61 lines (56 loc) · 978 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <cmath>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
using namespace std;
int main(){
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt","w",stdout);
#endif
int n,min=INT_MAX;
cin>>n;
std::vector<int> v;
std::vector<int> v2;
for (int i = 0; i < n; i++)
{
int x;
cin>>x;
v.pb(x);
}
if(abs(v[n-1]-v[0])<min){
min=abs(v[n-1]-v[0]);
v2.pb(1);
v2.pb(n);
}
if(abs(v[1]-v[0])<min){
min=abs(v[1]-v[0]);
v2.clear();
v2.pb(2);
v2.pb(1);
}
for(int i=1;i<n-1;i++){
int left=abs(v[i+1]-v[i]);
int right =abs(v[i-1]-v[i]);
if(left<min){
min=left;
v2.clear();
v2.pb(i+2);
v2.pb(i+1);
}
if(right<min){
min=right;
v2.clear();
v2.pb(i+1);
v2.pb(i+2);
}
}
for(int i=0;i<v2.size();i++){
cout<<v2[i]<<" ";
}
cout<<"\n";
return 0;
}