-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathJonny max chochlates.cpp
53 lines (38 loc) · 1.25 KB
/
Jonny max chochlates.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
#include<stdio.h>
#include<vector>
using namespace std;
int main()
{
int n;
vector<int> v;
vector<int>::iterator it;
scanf("%d",&n);
int x;
while(n!=0)
{
scanf("%d",&x);
v.push_back(x);
n--;
}
/*for(int i=0;i<v.size();i++)
printf("%d\n", v[i]);*/
vector<int> v_left;
long sum2=*(v.begin());
long sum1=0;
int i=1;
for(it=v.begin()+i;it!=v.end();it++)
{
if(sum1>=sum2)
sum2=sum2+(*it);
else
{
sum1=sum1+(*it);
v_left.push_back(i+1);
}
i++;
}
for(int i=0;i<v_left.size();i++)
printf("%d\n", v_left[i]);
system ("pause");
return 0;
}