mac_n_cheese_pog's blog

By mac_n_cheese_pog, history, 3 years ago, In English

https://codeforces.com/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.

  • Vote: I like it
  • -33
  • Vote: I do not like it

| Write comment?
»
3 years ago, # |
  Vote: I like it +6 Vote: I do not like it

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. :/

»
3 years ago, # |
  Vote: I like it 0 Vote: I do not like it

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.