Three Vault Equalizer
Preview mode. Log in to edit, run, submit, and save progress.
Three Vault Equalizer
Three finance vaults contain balances a, b, and c. An auditor also has a reserve bag with n extra coins. All reserve coins must be distributed among the vaults, and after distribution the three final balances must be exactly equal. For every audit row, decide whether such a distribution is possible. Input Format: The first line contains t, the number of test cases. Each test case contains four integers a, b, c, and n. Output Format: For each test case, print YES if the vaults can be equalized, otherwise print NO.
Examples
1 5 3 2 8
YES
Explanation: After adding the 8 reserve coins, the total balance is 18. The vaults can each finish with balance 6.
Approach hint
Start with the simplest clear approach, explain the trade-off, then move toward the cleaner answer.
Common mistake
Skipping assumptions, edge cases, or trade-offs can make an otherwise good answer feel incomplete.