Erase to max
Practice
3.5 (8 votes)
Basic programming
Basics of implementation
Easy
Implementation
Problem
52% Success 3502 Attempts 20 Points 3s Time Limit 256MB Memory 1024 KB Max Code
You are given an array \(A\) of size \(N\). You have to select any value '\(x\)' from \(A\) and remove its all occurrences. You need to perform this operation exactly once.
You need to obtain the maximum possible final sum of \(A\).
Input format
- First line: A number \(T\) denoting the total number of test cases
For each test case:
- First line: A number \(N\) denoting size of \(A\)
- Next line: \(N\) space-separated integers denoting the array \(A\)
Output format
Print the maximum possible sum of \(A\) after performing the operation exactly once.
Constraints
\(1 \le T \le 10\)
\(1 \le N \le 10^5\)
\(1 \le A[i] \le 10^6\)
Submissions
Please login to view your submissions
Similar Problems
Points:20
19 votes
Tags:
ApprovedBasic ProgrammingBasics of ImplementationEasyGrammar-VerifiedImplementationReadyRecruitSimulation
Points:20
44 votes
Tags:
ApprovedBasic ProgrammingEasy
3.War
Points:20
87 votes
Tags:
ApprovedBasic ProgrammingEasyOpen
Editorial