-
Notifications
You must be signed in to change notification settings - Fork 0
/
A.c
53 lines (53 loc) · 1.02 KB
/
A.c
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
#include<stdio.h>
int main()
{
int n,i,a[105],sum=0,count=0,p[105],q;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
sum=sum+a[i];
}
q=a[0];
if(a[0]>sum/2)
{
printf("1\n");
printf("1\n");
}
else
{
for(i=1;i<n;i++)
{
if(a[0]>sum/2)
break;
else if(count==0)
{
if(a[i]<=q/2)
{
count=2;
p[0]=1;
p[1]=i+1;
a[0]=a[0]+a[i];
}
}
else
{
if(a[i]<=q/2)
{
p[count]=i+1;
a[0]=a[0]+a[i];
count++;
}
}
}
if(a[0]<sum/2+1)
printf("0");
else
{
printf("%d\n",count);
for(i=0; i<count; i++)
printf("%d ",p[i]);
}
}
return 0;
}