Help! My program run successfully and even shows the output correct, but after submitting it shows partially correct

After submitting, it shows partially correct and a TLE error.
How do I solve overcome that error?
I am pasting my code below, can anyone help?
problem code: INOI1202
# n = list(map(int, input()))
N = int(input())
M = list(map(int, input().split(" ")))

size = N
flag = 0

a3 = []
maxSum = 0

for x in range(size):

if flag == 0:
	n = []
	for i in range(1, N + 1):

	for i in range(N):
		if M[i] + n[i] > maxSum:
			maxSum = M[i] + n[i]

	flag = 1

	maxSum = 0
	max = size - 1
	tempf = n[0]

	for i in range(size-1):
		n[i] = n[i+1]

	n[max] = tempf
	w = []

	for i in n:

	for i in range(N):
		if M[i] + w[i] > maxSum:
			maxSum = M[i] + w[i]

for i in a3:
print(i,end=" ")

Hey Buddy!!

When you use the sample test cases provided, the size is very small and it is possible to get correct result even if there is some error in code.

And many times your code might be right but the logic you use might not be fast enough to complete the task in provided time limit which raises TLE error which means Time Limit Exceeded. This seems to be the problem in your case

try a different approach and from next time attach the link to solution instead of copying it here as it becomes a mess here.

Hope you understood the problem

1 Like