title: Wants to know where I get wrong
body: <p>You are going to receive  payments in the upcoming month. The payments are numbered from  to  and denotes the amount of money in dollars that will be paid in connection with the <strong>i</strong>-th payment. Before receiving the payments, you have two banking options to consider:</p>
  
  <ol>
  <li>You can receive all the payments on your current bank account remembering that the bank charges you for each payment i max(<strong>k</strong>,<strong>x</strong>% of <strong>p_i</strong> ) , where k and x  are given.</li>
  <li>You can pay the bank <strong>d</strong> dollars upfront to open a new special account for which the bank doesn't charge you for any of the upcoming transactions.</li>
  </ol>
  
  <p>Your task is to decide which of the above two options is more profitable to you. If both ways are equally profitable, then you prefer to be charged for each transaction.</p>
  
  <p>Input Format</p>
  
  <p>In the first line, there is a single integer,<strong>q</strong>  denoting the number of scenarios to handle. After that, descriptions of all these scenarios follow. In the first line of a single scenario, there are  space-separated integers . In the second line, there are  space separated integers p_0,p_1,p_2,...p_(n-1).</p>
  
  <p>Constraints:</p>
  
  <pre><code>1&lt;=q&lt;=5
  1&lt;=n&lt;=100
  1&lt;=p_i&lt;=1000
  1&lt;=k&lt;=1000
  1&lt;=x&lt;=100
  1&lt;=d&lt;=100000
  </code></pre>
  
  <p>print fee if it's more profitable to use the current account and let the bank charge for each transaction, or print upfront if it's better to pay the bank up front for opening the new special account.</p>
  
  <p>Below is my code: I am not sure why it does not cover all the cases, please enlighten me on this, thank you!</p>
  
  <pre><code>string feeOrUpfront(int n, int k, int x, long int d, vector &lt;int&gt; p)
   {
      double sum=0;
      double amountcharged;
  
      amountcharged=0;
      for (int i=0;i&lt;n;i++)
      {  
          if  ((p[i]*x/100)&gt;k)
          {amountcharged=p[i]*x/100;}
          else
          {amountcharged=k;}
  
          sum=sum+amountcharged;
      }
  
      if (sum&gt;d)
      {
          return "upfront";
      }
      else
      {
          return "fee";
      }
  }
  
  int main() {
      int q;
      cin &gt;&gt; q;
      for(int a0 = 0; a0 &lt; q; a0++){
          int n;
          int k;
          int x;
          int d;
          cin &gt;&gt; n &gt;&gt; k &gt;&gt; x &gt;&gt; d;
          vector&lt;int&gt; p(n);
          for(int p_i = 0; p_i &lt; n; p_i++){
             cin &gt;&gt; p[p_i];
          }
          string result = feeOrUpfront(n, k, x, d, p);
          cout &lt;&lt; result &lt;&lt; endl;
      }
      return 0;
  }
  </code></pre>