Bob and Sticks


Submit solution

Points: 12 (partial)
Time limit: 1.0s
Python 2.0s
Memory limit: 256M

Author:
Problem type

There are two things Bob loves: sticks and equilateral triangles.

He has \(N\) (\(3 \le N \le 1000\)) sticks of varying lengths. Stick \(i\) (\(1 \le i \le N\)) has integer length \(a_i\) (\(1 \le a_i \le 500\)). The sum of all \(a_i\) is guaranteed to be \(\le 5000\).

Wanting to combine the two things he loves most, he wonders if he can align his sticks to form an equilateral triangle.

In other words, can he split his sticks into three groups such that the sum of lengths of sticks in each group is the same?

Input Specification

The first line has the integer \(N\): the number of sticks Bob has. The second line contains \(N\) space-separated integers \(a_1...a_N\).

Output Specification

Print Yes if Bob can make an equilateral triangle. If not, print No.

Sample Input 1

6
4 1 1 2 3 1

Sample Output 1

Yes

Sample Input 2

4
1 2 3 2

Sample Output 2

No

Comments


  • 1
    yujh  commented on Oct. 17, 2025, 4:33 p.m.

    Weak bounds


    • 1
      Ivan_Li  commented on Oct. 18, 2025, 12:05 a.m.

      The bounds are fine, I think (assuming bitset solution is intended).

      The data is really weak however, here's some hacks:

      9
      10 1 6 4 8 6 10 5 1

      Should be "Yes" since

      [10, 1, 6] = 17
      [4, 8, 5]  = 17
      [6, 10, 1] = 17

      Also

      8
      5 5 1 2 5 1 5 3

      Should be "No" since we need to sum to 9 and there's 4 5, forcing one group to have 10.


  • 0
    Ethan  commented on Oct. 16, 2025, 1:19 p.m.

    i saw what you did jadenfu


  • 0
    lerp  commented on Oct. 16, 2025, 1:18 p.m.

    Weak info

    Remove clipped output, put new cases, rejudge