title: TLE to HOTELS (spoj)
body: <p>I am doing a problem of spoj i tried to do it but I am always getting TLE(time limit expired )
  the question is <a href="http://www.spoj.pl/problems/HOTELS/" rel="nofollow">Hotels</a> . this is my code , please can you tell me the way to optimize it.</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  
  int main()
  {
      unsigned long long int a,b,i;
      scanf("%llu %llu",&amp;a,&amp;b);
      unsigned long long int arr[a];
      for(i=0;i&lt;a;i++)
      {
          scanf("%llu",&amp;arr[i]);
      }
  
  
          unsigned long long int d;
          unsigned long long int k,z=0;
      for(i=0;i&lt;a;i++)
      {
          d = arr[i];
          for(k=i+1;k&lt;a+1;k++)
          {
              if (d&lt;b)
              {
                  if(z&lt;d)
                  z = d;
              }
              else
              if(d==b)
              {
                  z = d;
                  break;
              }
              else
              break;
              d = d + arr[k];
          }
          if(d==b)
          break;
      }
      printf("%llu",z);
      return 0;
  }
  </code></pre>
  
  <p>in this like if input 5 12  , these five are 2 1 3 4 5 to make 12 then i do like this :
  first i compare 12 with 2 , then 2+1 , then 2+1+3 and so on after it goes to 5 it compares 12 to 1 , 1+3 , 1+3+4 .. and in this way i am taking only consecutive and break when i find equal to 12 otherwise it goes on till last.</p>
  
  <p>Hitesh</p>