CODECHEF - L56GAME


Problem Code : L56GAME

Problem      : Chef and Game with Sequence

Platform     : Codechef

Type         : Lunch Time

Language     : C 

Link         : CODECHEF


1:  //working  
2:  //no option to submit  
3:  //https://www.codechef.com/LTIME56/problems/L56GAME  
4:  #include <stdio.h>  
5:  #include <string.h>  
6:  #include <stdlib.h>  
7:  void func()  
8:  {  
9:       int n;  
10:       scanf("%d",&n);  
11:       int i;  
12:       int odd=0;  
13:       int even=0,temp;  
14:       for(i=0;i<n;i++)  
15:       {  
16:            scanf("%d",&temp);  
17:            if(temp%2==0)  
18:            {  
19:                 even++;  
20:            }  
21:            else  
22:            {  
23:                 odd++;  
24:            }  
25:       }  
26:       int ans=0;  
27:       ans=ans+ (odd%2);  
28:       even = even+ (odd/2);  
29:       if(even>0)  
30:       {  
31:            ans++;  
32:       }  
33:       printf("%d\n",ans );  
34:  }  
35:  int main()  
36:  {  
37:       int cases;  
38:       scanf("%d",&cases);  
39:       while(cases--)  
40:       {  
41:            func();  
42:       }  
43:       return 0;  
44:  }  

Comments

Popular

Traversal In A Binary Tree - Tree -3

Pre Order Traversal In Binary Tree

Tree data structure - 2