daily pastebin goal
35%
SHARE
TWEET

Untitled

a guest Jul 20th, 2018 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <cstdio>
  2. #define FOR(i,a,b) for(i=a; i<=b; i++)
  3. using namespace std;
  4. int solve()
  5. {
  6.     int N,a,f,i,s,t;
  7.     scanf("%d",&N);
  8.     scanf("%d %d",&f,&s);
  9.     a = s;
  10.     FOR(i,3,N)
  11.     {
  12.         t = s;
  13.         s = 2 * a - f;
  14.         f = 2 * a - t;
  15.         scanf("%d",&a);
  16.         if(a < f) return 0;
  17.         if(a < s) s = a;
  18.     }
  19.     return s - f + 1;
  20. }
  21. int main()
  22. {
  23.     printf("%d\n" , solve() );
  24.     return 0;
  25. }
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