#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define crep(i,x,n) for(int i=x;i<n;i++)
#define drep(i,n) for(int i=n-1;i>=0;i--)
#define vec(...) vector<__VA_ARGS__>
#define _34raRxL ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
void print(){
cout<<"\n";
}
template<class te,class ...ti>
void print(const te&v, const ti&...nv) {
cout<<v;
if(sizeof...(nv)){
cout<<" ";
print(nv...);
}
}
#define yare {cout<<"DA\n"; exit(0);}
#define nare {cout<<"NE\n"; exit(0);}
using tpii=pair<ll,pair<ll,ll>>;
using pii=pair<int,int>;
using vi=vector<int>;
using vll=vector<long long>;
const int inf=1e9+11;
signed main(){
_34raRxL;
int n;
cin>>n;
vll a(n);
rep(i,n){
cin>>a[i];
}
ll ans=inf;
rep(i,n){
if(i-1>=0){
ans=min(ans,abs(a[i]-a[i-1]));
}
}
print(ans,"\n");
//
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
312 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
11 ms |
1036 KB |
Output is correct |
6 |
Correct |
14 ms |
1040 KB |
Output is correct |
7 |
Correct |
10 ms |
1044 KB |
Output is correct |