Computer Science, asked by rajansandilya360, 7 days ago

Problem Statement
1
с
4
2
Avi found X random elements. They have a fixed colour & size. For every ith element, i
represents the colour and Ci the size.
An element can absorb another element whose size is <= 2x the size of itself.
When an element of size Z and colour Y absorbs another creature of size V and colour T,
they will merge into one creature of size Z+V and colour Y. It's strange that depending on
the sizes of 2 elements, it is possible that both of them can absorb each other.
Avi has been watching these elements merging and forming one really large element in the
end.
min 00 oo
6
7
8
9
Find all the possible colours of this element.
10
Constraints
• 2 <= x <= 10^5
Light
• 1 <= Ci <= 1049
• Ci is an integer.
Rules
Input Format
Input is given from Standard Input in the following format:
X
Finish
C1 C2 ...CN
Output Format

Answers

Answered by dvprabhavathisanju
0

Answer:

I don't know the answer

Explanation:

thank you

Answered by nehalagrawal186
0

answer

int main() {

vector<int> v ;

v.push_back(3);

v.push_back(1);

v.push_back(4);

int sum = accumulate(v.begin(), v.end(), 0);

sort(v.begin(),v.end());

int ans = 0;

int i = 0;

int temp = 0;

while( i< v.size() ){

int j = i+1;

temp += v[i];

int a = temp;

while(j<v.size() ){

if(a*2>=v[j]){

a += v[j];

}

else{

break;

}

j++;

}

if(a == sum){

ans++;

}

i++;

}

cout<<ans;

return 0;

}

Similar questions