Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <map>
- #include <string.h>
- #include <math.h>
- #include <set>
- #include <stack>
- #include <queue>
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define cy cout << "YES\n"
- #define cn cout << "NO\n"
- #define nl "\n"
- #define fi first
- #define se second
- #define MOD 1000000007
- #define all(v) v.begin(), v.end()
- #define rall(v) v.end(), v.begin()
- #define sz(s) s.size()
- #define f0r(j, n) for (ll i = j; i < n; i++)
- template <typename T = int>
- istream &operator>>(istream &in, vector<T> &v)
- {
- for (auto &x : v)
- in >> x;
- return in;
- }
- template <typename T = int>
- ostream &operator<<(ostream &out, const vector<T> &v)
- {
- for (const T &x : v)
- out << x << " ";
- return out;
- }
- void sherry()
- {
- ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
- #ifndef ONLINE_JUDGE
- freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
- #endif
- }
- /*
- int gcd(ll a, ll b)
- {
- if (b == 0)
- return a;
- return (b, a % b);
- }
- */
- void solve()
- {
- int n;
- cin >> n;
- vector<int> v(n);
- cin >> v;
- set<int> st;
- sort(all(v));
- for (int i = 0; i < n - 1; i++)
- {
- st.insert(v[i + 1] - v[i]);
- if (i + 2 < n)
- st.insert(v[i + 2] - v[i]);
- }
- int i = 0;
- for (auto &x : st)
- {
- i++;
- if (i == 3)
- {
- cout << x << nl;
- return;
- }
- }
- }
- int main()
- {
- sherry();
- int t = 1;
- // cin >> t;
- while (t--)
- solve();
- return 0;
- }
- // 5 1 0 3 4 2
- // 2 5 5 6 7
- // 3 1 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement