fork download
  1. #include <bits/stdc++.h>
  2. typedef long long ll;
  3. using namespace std;
  4. void Code_By_Mohamed_Khaled() {
  5. ios_base::sync_with_stdio(false);
  6. cin.tie(nullptr);
  7. cout.tie(nullptr);
  8. }
  9. int main() {
  10. Code_By_Mohamed_Khaled();
  11. ll t;cin>>t;
  12. while (t--) {
  13. ll n,h;cin>>n>>h;
  14. vector<ll>v(n);
  15. for (auto &it:v)cin>>it;
  16. ll l=1,r=h,ans=h;
  17. while (l<=r) {
  18. ll mid=(l+r)/2;
  19. ll total=0;
  20. for (ll i = 0; i < n - 1; i++) {
  21. total+=min(mid, v[i+1]-v[i]);
  22. }
  23. total+=mid;
  24. if (total>=h) {
  25. ans=mid;
  26. r=mid-1;
  27. }
  28. else l=mid+1;
  29. }
  30. cout<<ans<<"\n";
  31. }
  32. return 0;
  33. }
Success #stdin #stdout 0.01s 5276KB
stdin
Standard input is empty
stdout
140729369623336