title: Getting WA in Google Kick Start Round A: (Workout Problem)
body: <h1><strong>Problem Description</strong></h1>
  <p>Tambourine has prepared a fitness program so that she can become more fit! The program is made of <strong>N</strong> sessions. During the i-th session, Tambourine will exercise for <strong>Mi</strong> minutes. The number of minutes she exercises in each session are strictly increasing.</p>
  <p>The difficulty of her fitness program is equal to the maximum difference in the number of minutes between any two consecutive training sessions.</p>
  <p>To make her program less difficult, Tambourine has decided to add up to <strong>K</strong> additional training sessions to her fitness program. She can add these sessions anywhere in her fitness program, and exercise any positive integer number of minutes in each of them. After the additional training session are added, the number of minutes she exercises in each session must still be strictly increasing. <strong>What is the minimum difficulty possible?</strong></p>
  <p><strong>Input</strong></p>
  <p>The first line of the input gives the number of test cases, <strong>T</strong>. T test cases follow. Each test case begins with a line containing the two integers <strong>N</strong> and <strong>K</strong>. The second line contains N integers, the i-th of these is <strong>Mi</strong>, the number of minutes she will exercise in the i-th session.</p>
  <p><strong>Output</strong></p>
  <p>For each test case, output one line containing Case #x: y, where x is the test case number (starting from 1) and <strong>y is the minimum difficulty possible after up to K additional training sessions are added.</strong></p>
  <p><strong>Limits</strong></p>
  <p>Time limit: 20 seconds per test set.</p>
  <p>Memory limit: 1GB.</p>
  <p>1 ≤ T ≤ 100.</p>
  <p>For at most 10 test cases, 2 ≤ N ≤ 10^5.</p>
  <p>For all other test cases, 2 ≤ N ≤ 300.</p>
  <p>1 ≤ Mi ≤ 10^9.</p>
  <p>Mi &lt; Mi+1 for all i.</p>
  <p><strong>Test set 1</strong></p>
  <p>K = 1.</p>
  <p><strong>Test set 2</strong></p>
  <p>1 ≤ K ≤ 10^5.</p>
  <h1><strong>MY APPROACH</strong></h1>
  <p>Using <strong>Priority Queue</strong>, Extracting Maximum from the Existing elements in the Priority Queue.</p>
  <p><strong>C++ code</strong></p>
  <pre><code>#include &lt;bits/stdc++.h&gt;
  using namespace std;
  
  void solve()
  {
      int n,k,x,prev = 0;
      cin&gt;&gt;n&gt;&gt;k;
      priority_queue&lt;int&gt; pq;
      for(int i=0;i&lt;n;i++)
      {
          cin&gt;&gt;x;
          if(prev != 0)
          {
              pq.push(x - prev);
          }
          prev = x;
      }
      while(k &gt; 0 &amp;&amp; !pq.empty())
      {
          int tmp = pq.top();
          if(tmp == 1)
          {
              break;
          }
          pq.pop();
          pq.push(tmp/2);
          pq.push(tmp - tmp/2);
          k--;
      }
      cout &lt;&lt; pq.top() &lt;&lt; &quot;\n&quot;;
  }
  
  int32_t main()
  {
      int t,i=1;cin&gt;&gt;t;
      while(t--)
      {
          cout &lt;&lt; &quot;Case #&quot; &lt;&lt; i &lt;&lt; &quot;: &quot;;
          solve();
          i++;
      }
      return 0;
  }
  </code></pre>