fork(39) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define oo 1000000010
  4. #define mod 1000000007
  5. const int N = 300010;
  6. int n , arr[N] ;
  7.  
  8. void solve(){
  9. int mn = oo , mx = -oo;
  10. scanf("%d",&n);
  11. for(int i=0;i<n;i++){
  12. scanf("%d",&arr[i]);
  13. }
  14. for(int i = 0;i<n;i++){
  15. if(i > 0 && arr[i] == -1 && arr[i - 1] != -1)
  16. mn = min(mn , arr[i - 1]) , mx = max(mx , arr[i - 1]);
  17. if(i < n - 1 && arr[i] == - 1 && arr[i + 1] != -1)
  18. mn = min(mn , arr[i + 1]) , mx = max(mx , arr[i + 1]);
  19. }
  20. int res = (mx + mn) / 2;
  21. int ans = 0;
  22. for(int i=0;i<n;i++){
  23. if(arr[i] == -1)
  24. arr[i] = res;
  25. if(i)
  26. ans = max(ans,abs(arr[i] - arr[i - 1]));
  27. }
  28. printf("%d %d\n",ans,res);
  29. }
  30.  
  31.  
  32. int main(){
  33. int t;
  34. cin >> t;
  35. while(t--){
  36. solve();
  37. }
  38. return 0;
  39. }
Success #stdin #stdout 0s 4176KB
stdin
Standard input is empty
stdout
Standard output is empty