Pypy3-64 being much slower than Python3 here

Правка en1, от vsvg, 2024-08-27 16:38:53

Can any one explain for 2003C - Turtle and Good Pairs, why PyPy3-64 is being slower here 278391142 and getting TLE and also the memory limit, when the same code works fine with Python3 here 278391153. Thought PyPy always works faster than Python, what am I missing?

import sys
input = lambda: sys.stdin.readline().strip()

for _ in range(int(input())):
    n = int(input())
    s = input()
    a = [0] * 26
    
    for i in range(n):
        a[ord(s[i]) - ord('a')] += 1

    res = ""

    while True:
        tempval = 0
        for i in range(26):
            if a[i] != 0:
                res += chr(i + ord('a'))
                a[i] -= 1
                tempval = 1
        
        if tempval == 0:
            break

    print(res)
Теги python3, pypy3-64, pypy

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский vsvg 2024-08-27 16:45:29 126 Tiny change: 'n~~~~~\n\n' -> 'n~~~~~\n\nNever faced such issue till now with PyPy3-64 :(\n\n\n\n' (published)
en1 Английский vsvg 2024-08-27 16:38:53 915 Initial revision (saved to drafts)