fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. public class Main
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. Scanner sc = new Scanner(System.in);
  13. int t = sc.nextInt();
  14. while(t-- >0){
  15. int n = sc.nextInt();
  16. int k = sc.nextInt();
  17. int [] a = new int[n];
  18. int l=0;
  19. int ans=0;
  20. for(int i=0;i<n;i++){
  21. int curr = sc.nextInt();
  22. ans = Math.max(ans,curr-l);
  23. l = curr;
  24. }
  25. ans = Math.max(ans,2*(k-l));
  26. System.out.println(ans);
  27.  
  28. }
  29.  
  30. }
  31. }
Success #stdin #stdout 0.13s 54512KB
stdin
3
3 7
1 2 5
3 6
1 2 5
1 10
7
stdout
4
3
7