problem : http://www.spoj.com/problems/FARIDA/

what is wrong with this code? The algorithm is pretty straight forward

#include<stdio.h>
#include<stdlib.h>
int main(void)
{
    int t,n,i;
    scanf("%d",&t);
    long long int s1,s2,s=0,a,temp;
    int c=1;
    while(t--)
    {
      scanf("%d",&n);
      if(n==0)
      { printf("Case %d: 0\n",c);
        c++;
        continue;
      }
      scanf("%lld",&s1);
      
      if(n==1)
      { printf("Case %d: %lld\n",c,s1);
        c++;
        continue;
      }
      scanf("%lld",&s2);
      
      for(i=2;i<n;i++)
       { scanf("%lld",&a);
         temp=s2;
         s2=s1+a>s2?s1+a:s2;
         s1=temp;
       }
       s=s1>s2?s1:s2;
       
       printf("Case %d: %lld\n",c,s);
       c++;
    } 
   // scanf("%d",&i);
    return 0;
}    


-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to algogeeks+unsubscr...@googlegroups.com.


Reply via email to