SHARE
TWEET

Untitled

a guest Feb 17th, 2018 372 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2.  
  3. #define forn(i, n) for (int i = 0; i < int(n); i++)
  4.  
  5. using namespace std;
  6.  
  7. const int INF = 1e7;
  8.  
  9. int n;
  10. vector<int> pos;
  11.  
  12. int main() {
  13.     scanf("%d", &n);
  14.     pos.resize(n);
  15.     forn(i, n)
  16.         scanf("%d", &pos[i]);
  17.    
  18.     int ans = INF;
  19.    
  20.     forn(i, n + 1){
  21.         int cur = 0;
  22.         if (i) cur = max(cur, pos[i - 1] - 1);
  23.         if (i != n) cur = max(cur, 1000000 - pos[i]);
  24.        
  25.         ans = min(ans, cur);
  26.     }
  27.    
  28.     printf("%d\n", ans);
  29. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top