Coins
Practice
2.9 (15 votes)
Algorithms
Binary search
Easy
Searching
Two pointer
Problem
93% Success 10412 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code
There are \(N\) bags and each bag contains some coin(s). Your task is to select an integer \(X\) and remove all the bags in which the number of coins is equal to \(X\). Divide the remaining bags into two non-empty groups such that:
- The number of coin(s) in each bag of the first group is strictly smaller than \(X\).
- The number of coin(s) in each bag of the second group is strictly larger than \(X\).
- The total number of coins of one group is equal to the other.
Input Format:
The first line contains an integer \(N\;(1 \le N \le 10^5)\) denoting the number of bags.
The second line contains \(N\) space-separated integers, denoting the number of coins in \(N\) bags. The \(i^{th}\) integer denotes the values of \(A_i \; (1 \le A_i \le 10^5)\).
Output Format:
Print \(YES\), if it is possible to divide the bags into two groups, else print \(NO\).
Submissions
Please login to view your submissions
Similar Problems
Points:20
62 votes
Tags:
Basic ProgrammingBinary SearchEasySearchingapproved
Points:20
272 votes
Tags:
ApprovedEasyMathReadySorting
Points:20
86 votes
Tags:
ApprovedBinary SearchEasyOpenSorting
Editorial