-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCodeforces1178A.cpp
58 lines (56 loc) · 953 Bytes
/
Codeforces1178A.cpp
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
55
56
57
58
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
main()
{
int n,i,j,k,l,m,sum=0,s=0;
cin>>n;
vector<int>v;
int a[n+2];
for(i=0;i<n;i++)
{
cin>>a[i];
sum+=a[i];
}
if(a[n-1]<a[0]/2)
{
cout<<0<<endl;
return 0;
}
if(n==2 && a[0]>a[1])
{
if(a[0]>a[1]){
cout<<1<<endl<<1<<endl;
}
else {
cout<<0<<endl;
}
return 0;
}
m=a[0];
bool flag=0;
s+=m;
v.pb(1);
for(i=1;i<n;i++)
{
if((a[i]*2)<=m)
{
s+=a[i];
v.pb(i+1);
}
if(s>sum/2)
{
flag=1;
break;
}
}
if(!flag) cout<<0<<endl;
else {
cout<<v.size()<<endl;
for(i=0;i<v.size();i++)
{
cout<<v[i]<<" ";
}
cout<<endl;
}
}