gokulraaj59's blog

By gokulraaj59, history, 5 weeks ago, In English

my code 169668033

getting TLE in test 2, have used fast_IO and verified this time complexity with solution solution blogalso.. have used same logic

what I am doing wrong here..


def remove(arr, ele): arr.remove(ele) return arr t = int(input()) for _ in range(0, t): n = int(input()) a = [] op = [] for i in range(1, n+1): a.append(i) # print(a) for i in range(0, n-1): # a.sort() x = a[-1] y = a[-2] a.append(round( (x+y)/2) ) op.append([x,y]) a = remove(a, x) a = remove(a, y) sys.stdout.write(str(a[0]) + "\n") for i in op: sys.stdout.write(" ".join(map(str,i)) + "\n")

Read more »

 
 
 
 
  • Vote: I like it
  • -1
  • Vote: I do not like it

By gokulraaj59, history, 7 weeks ago, In English

1466B - Last minute enhancements 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 ???

Read more »

 
 
 
 
  • Vote: I like it
  • 0
  • Vote: I do not like it

By gokulraaj59, history, 3 months ago, In English

code here have made this code in python its giving TLE on Test-16 -> and have also tried with Fast_IO and PyPy too code

please need solutions in python only.

Read more »

 
 
 
 
  • Vote: I like it
  • +3
  • Vote: I do not like it

By gokulraaj59, history, 3 months ago, In English

[submission:161414953][submission:161413119] T-primes I have don this problem in py3 and all the logic part is correct and while running local run time = 600ms codeforce runtime TLE

can any one help me with this my code --> """ import math

def callone(num): def prime(n): prime_flag = 0 if(n > 2): for i in range(2, int(math.sqrt(n)) + 1): if (n % i == 0): prime_flag = 1 break if (prime_flag == 0): return 1 else: return 0 else: return 0

if(num > 4):
    x = math.sqrt(num)
    s = str(x)
    if(s[-2:] == '.0'):
        if(prime(x)):
                return 1
        else:
            return 0
    else:
        return 0
else:
    return 0

def array(num): ele = 3 primearr = [] while(ele < num+1): for i in range(2, int(math.sqrt(ele)) + 1): if (ele % i == 0): break else: primearr.append(ele) ele+=1 return(primearr)

def call(num): if(num > 4): x = math.sqrt(num) s = str(x) if(s[-2:] == '.0'): return 1 else: return 0 else: return 0

n = int(input()) arr = list(map(int, input().split()))

if len(arr) > 1: m = int(math.sqrt(max(arr))) primearr = array(m) # print(primearr) for i in arr: if(i==4): print('YES') elif(i%2==0): print('NO') elif(call(i) and (int(math.sqrt(i)) in primearr)): print("YES") else: print("NO") else: if(callone(arr[0])): print("YES") else: print("NO")

"""

Read more »

 
 
 
 
  • Vote: I like it
  • -1
  • Vote: I do not like it