#pragma GCC optimize("unroll-loops,Ofast,O3")
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define spc << " " <<
#define endl "\n"
#define all(x) x.begin(), x.end()
#define int long long
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define st first
#define nd second
#define inf 1000000009
#define MOD 998244353
#define lim 200005
using namespace std;
void solve(){
int n; cin >> n;
int temp; cin >> temp;
int ans=inf;
for(int i=2; i<=n; i++){
int a; cin >> a;
ans = min(ans, abs(a-temp));
temp=a;
}
cout << ans << endl;
}
signed main(){
ios_base::sync_with_stdio(false);cin.tie(0);
#ifdef Local
freopen("in","r",stdin);
freopen("out","w",stdout);
#endif
/*freopen("fcolor.in","r",stdin);
freopen("fcolor.out","w",stdout);*/
int t=1;
//cin >> t;
while(t--) solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
7 ms |
348 KB |
Output is correct |
6 |
Correct |
8 ms |
348 KB |
Output is correct |
7 |
Correct |
7 ms |
344 KB |
Output is correct |