PERCAPTA - Editorial

Definitely you should brother. Python may seem very handy for easy, easy-medium questions, but when it comes to strict time-limits and long implementations, there’s no beating C++.

2 Likes

Codechef stills give 5X for Python (though Python may TLE within that range as well) but Codeforces doesn’t give any multiplier to Python. Secondly, implementation of most of the tough topics is only given in cpp and as always cpp is fast. So, you’re right.

Actually, the time multiplier for PYPY is 2, but for Pyhton 3. it’s 5. That’s why you got accepted submitting in Pyhton 3 but not in PYPY.

Faced similar issue man :frowning:

https://www.codechef.com/viewsolution/34616442

But PyPy is faster than Python. So, that is why Multiplier of PyPy is less. My Solution in PyPy gave TLE during the contest and got accepted in Python. Now the same solution after the contest is giving AC in both.

Can someone explain me this test-case ?

1
4 4
10 1 2 100000000
5 1 1 1
1 2
2 3
1 3
2 4

We are not considering 2nd node as explained above but if I considered 2nd node then I can consider 4th node as well and it will increase per capita income

Not considering 2nd node:
X = (10+2)/(5+1)

Considering 2nd and 4th node:
Y = (10+2+1+100000000)/(5+1+1+1)

Clearly, Y > X

@taran_1407
@rezwanarefin01
@raja1999

Why don’t you consider 100000000/1 ??

2 Likes

Can someone help. I did exactly the same thing as the editorial. Used BFS approach. Here is my solution.

I got wa when I used double and got ac by using long double

That’s nice. But sometimes you can lose precision even with long double. So it’s always best to use integer comparison if it’s possible.

You must have done something else wrong, because I got AC on double.

Hi guys Try this video solution: [Per Capita Income]](Codechef June Cook-Off 2020 | |Per Capita Income || Steps and explaination || CODECHEF - YouTube)

even i also applied the same approach ,but getting TLE.I also tried implementing using scanf and printf for i/o but still getting TLE

Thanks

1 Like

Nice question.

Hi guys try this video solution :raised_hands::raised_hands:

Very week testcases, have a look at this

You should have add some testcases with these corner cases

I have used the same dfs approach, but getting wa verdict. Can someone please help. Thanks!!
https://www.codechef.com/viewsolution/34626836

Edit: that’s due to integer overflow :cry: changed to long long, got AC.