Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_DISABLE_PERFCRIT_LOCKS
- #include<bits/stdc++.h>
- #define ll long long int
- #define pb push_back
- #define ifor for(i=0; i<n; i++)
- using namespace std;
- ll INF=1e18;
- int main()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL); cout.tie(NULL);
- ll n, i, j, x, y, mindis=INF, kol;
- cin>>n;
- vector < ll > a(n);
- ifor
- {
- cin>>a[i];
- }
- sort(a.begin(), a.end());
- ll dis;
- mindis=abs(a[1]-a[1-1]);
- kol=1;
- for(i=2; i<n; i++)
- {
- dis=abs(a[i]-a[i-1]);
- if(dis==mindis) {kol++; }
- if(dis<mindis) {mindis=dis; kol=1;}
- }
- cout<<mindis<<" "<<kol<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement