1 min read

In this blog we are going to solve a problem on **codeforces**. You can read the problem statement here.

**Explaination**:-

If the current position is (0, 0, 0) then body will be in equilibrium if and only if all the sum of the resolution is zero i.e.

x1 + x2 + x3 + … + xn = 0

y1 + y2 + y3 + … + yn = 0

z1 + z2 +z3 + … + zn = 0

So to solve this problem we have to find the sum of all the resolution and then print the output.

So the code for this solution is : –

n = int(input()) vec = [] for i in range(n): vec.append(list(map(int,input().split()))) sum1, sum2, sum3 = 0, 0, 0 for i in range(n): sum1 += vec[i][0] sum2 += vec[i][1] sum3 += vec[i][2] if sum1 == 0 and sum2 == 0 and sum3==0: print("YES") else: print("NO")

You must be logged in to post a comment.