Same code with Pypy3 and Python3 but with different results

Revision en1, by Achilles221B, 2020-05-23 15:37:53

Today when my brother was trying to solve 1355B - Young Explorers with Python3. He got wrong answer on Test 10.

81011086

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

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?

Tags #python3, #pypy3, #python, #pypy

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English Achilles221B 2020-05-23 15:37:53 1270 Initial revision (published)