fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long int
  4.  
  5. int main() {
  6. int t;
  7. cin>>t;
  8. while(t--){
  9. int n, x;
  10. cin>>n>>x;
  11. int ans = 0, prev = 0;
  12. for(int i=0;i<n;i++){
  13. int a;
  14. cin>>a;
  15. ans=max(ans, a-prev);
  16. prev=a;
  17. }
  18. ans= max(ans, 2*(x-prev));
  19. cout<<ans<<endl;
  20. }
  21. return 0;
  22. }
Success #stdin #stdout 0.01s 5272KB
stdin
3
3 7
1 2 5
3 6
1 2 5
1 10
7
stdout
4
3
7