Ankit_132

A

Jun 6th, 2024
1,718
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.38 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main(){
  5.    int t;
  6.    cin>>t;
  7.    while (t--){
  8.         int n;
  9.         cin >> n;
  10.         vector<int> x(n);
  11.         for(int i = 0; i < n; i++) cin >> x[i];
  12.         int count = 1e9;
  13.         for(int i = 1; i < n; i++){
  14.             count = min(count, max(x[i], x[i - 1]) - 1);
  15.         }
  16.         cout << count << '\n';
  17.    }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment