title: UVA OnlineJudge 507 - Jill Rides Again wrong answer
body: <p>I've been doing <a href="https://uva.onlinejudge.org/index.php?option=com_onlinejudge&amp;Itemid=8&amp;page=show_problem&amp;category=&amp;problem=448&amp;mosmsg=Submission%20received%20with%20ID%2015981694" rel="nofollow">UVA OnlineJudge 507 - Jill Rides Again</a>. I wrote the code and it works on every testcase from 'debug' page and form other forum.
  But when I submitted to the online judge, it became wrong answer.
  Here is my code</p>
  
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;stdio.h&gt;
  int main() {
      int stop[30000];
      int n, m, i, j, ans, sum, imax, imin, tmin, a = 1;
  
      scanf("%d", &amp;n);
      while (n--) {
          // get all values
          scanf("%d", &amp;m);
          stop[0] = 0;
          for (i = 1; i &lt; m; i++) scanf("%d",&amp;stop[i]);
  
          sum = ans = imax = imin = tmin = 0;
          for (i = 1; i &lt; m; i++) {
              sum += stop[i];
              if (sum &gt; ans || (sum == ans &amp;&amp; (i - tmin) &gt; (imax - imin))) {
                  ans = sum;
                  imax = i;
                  imin = tmin;
              }
  
              if (sum &lt;= 0) {
                  tmin = i;
                  sum = 0;
              }
          }
  
          if (ans &gt; 0) {
              printf("The nicest part of route %d is between stops %d and %d\n", a++, imin + 1, imax + 1);
          } else {
              printf("Route %d has no nice parts\n", a++);
          }
      }
      return 0;
  }
  </code></pre>
  
  <p>What is wrong with my code?</p>