-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMixi Game.c
More file actions
54 lines (49 loc) · 844 Bytes
/
Mixi Game.c
File metadata and controls
54 lines (49 loc) · 844 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include<stdio.h>
#include<math.h>
void main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n,k,sum=0;
scanf("%d%d",&n,&k);
int a[n],i,count=0;
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
if(a[i]==1)
count++;
}
if(count>=k)
{
for(i=0;i<n;i++)
{
if(i%2==0)
{
if(sum>0)
sum=sum+a[i];
else
sum=sum-a[i];
}
else
{
if(sum>0)
sum=sum-a[i];
else
{
sum=sum+a[i];
}
}
}
if(abs(sum)>=k)
printf("1\n");
else
printf("2\n");
}
else
{
printf("2\n");
}
}
}