YEZAELP

PROG-1116: schoolbus

Jun 10th, 2021
789
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. using lli = long long;
  5. const int N = 1e6;
  6. const int D = 1e9 + 1e6;
  7. const int INF = 1e18;
  8. int ar[N+10], mn[N+10];
  9. int main(){
  10.  
  11.     int n;
  12.     scanf("%d", &n);
  13.  
  14.     for(int i=1;i<=n;i++){
  15.         scanf("%d", &ar[i]);
  16.     }
  17.  
  18.     mn[n] = ar[n];
  19.     for(int i=n-1;i>=1;i--){
  20.         mn[i] = min(ar[i], mn[i+1]);
  21.     }
  22.  
  23.     double mx = 0.0;
  24.     for(int i=1;i<=n;i++){
  25.         mx = max(mx, (double)(ar[i] - mn[i])/2);
  26.     }
  27.  
  28.     printf("%.6f", mx);
  29.  
  30.     return 0;
  31. }
  32.  
RAW Paste Data