Today when my brother was trying to solve 1355B - Young Explorers with Python3. He got wrong answer on Test 10.
81011086 May/23/2020 13:44UTC+2 ThetaSigma B — Young Explorers Python 3 Wrong answer on test 10
When he told me about his solution, I thought about it for a bit and I couldn't come up with anything. So I just tried submitting it with PyPy3 and weirdly enough it got accepted.
81011123 May/23/2020 13:45UTC+2 ThetaSigma B — Young Explorers PyPy 3 Accepted
For anyone curious, here's the code:
from sys import stdin
def inp():
return stdin.readline().strip()
t = int(inp())
for _ in range(t):
n = int(inp())
e = [int(x) for x in inp().split()]
e.sort()
x = list(set(e))
big = max(e)
results = {}
for i in e:
if results.get(i,0):
results[i] += 1
else:
results[i] = 1
groups = 0
counter = 1
for i, j in results.items():
groups += j//i
if i != big:
results[x[counter]] += j%i
counter += 1
print(groups)
Does anyone have any idea about what's happening here?