Skip to main content
Back to problems
Codeforces
Easy
Arrays
Math
Young Physicist

Check whether a set of 3D force vectors adds up to the zero vector.

Acceptance 0%
Problem Statement

Young Physicist

You are given nn force vectors in 3D space. Each vector is described by its xx, yy, and zz components.

Your task is to determine whether the physicist can keep the body in equilibrium, which happens exactly when the sum of all vectors is the zero vector.

In other words, after adding all xx components together, all yy components together, and all zz components together, each total must be $0$.

Print YES if the body is in equilibrium, otherwise print NO.

Input Format

  • The first line contains an integer nn.
  • Each of the next nn lines contains three integers xx, yy, and zz describing one vector.

Output Format

  • Print YES if the sum of all vectors is (0,0,0)(0, 0, 0).
  • Otherwise print NO.

Constraints

  • 1≤n1 \le n
  • Each coordinate is an integer.
  • The exact bounds are not required for solving this task; use integer arithmetic.
Examples
Sample cases returned by the problem API.

Example 1

Input

3
4 1 7
-2 4 -1
-2 -5 -6

Output

YES

Explanation

The component-wise sums are 4−2−2=04-2-2=0, 1+4−5=01+4-5=0, and 7−1−6=07-1-6=0.

Example 2

Input

3
3 -1 7
-5 2 -4
2 -1 -2

Output

NO

Explanation

The sums are 3−5+2=03-5+2=0, −1+2−1=0-1+2-1=0, and 7−4−2=17-4-2=1, so the result is not the zero vector.

Premium problem context

Unlock deeper context for this problem

Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.