Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define forn(i, n) for (int i = 0; i < int(n); i++)
- using namespace std;
- const int INF = 1e7;
- int n;
- vector<int> pos;
- int main() {
- scanf("%d", &n);
- pos.resize(n);
- forn(i, n)
- scanf("%d", &pos[i]);
- int ans = INF;
- forn(i, n + 1){
- int cur = 0;
- if (i) cur = max(cur, pos[i - 1] - 1);
- if (i != n) cur = max(cur, 1000000 - pos[i]);
- ans = min(ans, cur);
- }
- printf("%d\n", ans);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement