1466B — Last minute enhancements

Правка en2, от gokulraaj59, 2022-08-16 12:59:03

1466B - Улучшения в последнюю минуту i have tried to solve this with a time complexity of O(n) even with Fast_IO too it gave me an TLE //python code

for t in range(0, int(input())):
    n = int(input())
    ar = list(map(int, input().split()))
    ar.sort()
    
    op = [ar[0]]
    
    for i in ar[1:]:
        op.sort()
        if op[-1] == i:
            op.append(i+1)
        else:
            op.append(i)
        
    # print(ar)
    # print(op)
    print(len(set(op)))
    # print()

my solution 168486304

can I have a better solution ???

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en3 Английский gokulraaj59 2022-08-16 13:03:11 8
en2 Английский gokulraaj59 2022-08-16 12:59:03 22 Tiny change: ' me an TLE\n~~~~~\nf' -> ' me an TLE //python code\n\n\n\n~~~~~\nf'
en1 Английский gokulraaj59 2022-08-16 12:54:28 595 Initial revision (published)