https://codeforces.net/contest/810/problem/B see this problem and see my code https://pastebin.com/U3p3vCwD
my approach: i make pair,find maximum v[i].first and then check if second is >0 then multiply it.
if u dont understand my code just try to analyze my code.i think its pretty straightforward.
most of the times, greedy algorithms that comes to our mind are wrong and there is nothing wrong in that but with practice intuition improves. I read this in a book. :/
How do you even know that it's wrong if you still haven't submitted your solution to codeforces judge? Do you maybe get a wrong answer for the examples given in the problem statement? There are some explanations about the examples in the Note section.
Also how do you know that it's "greedy"? Is your account configured to show tags for unsolved problems? This information is a major spoiler and generally makes practice much less efficient.