https://www.codechef.com/viewsolution/17540209 <=== solution
https://www.codechef.com/problems/MAXSC/ <----problem!
getting runtime error!
https://www.codechef.com/viewsolution/17540209 <=== solution
https://www.codechef.com/problems/MAXSC/ <----problem!
getting runtime error!
for i in range(n-2,-1,-1):
if lst[i][-1]>prev:#Should be >= , else it will fail on some cases.
for j in range(n-1,-1,-1):
if lst[i][j]<prev:
total+=i[j]//i[j]? I think you meant lst[i][j]. This line causes NZEC.
prev=lst[i][j]
break
total=-1
Additionally, your code fails here-
Input
1
2
1 2
1 2
Your Output
-1
Expected Output
3
Break out of your look as soon as you see total is -1
and its impossible to satisfy the condition. The case-
Input
1
3
1 1 1
9 9 9
8 8 8
Your output
0
Expected Output
-1
What went wrong?
Total went to -1 in row 2, and then you added 1 again while traversing row 1.
WORKED! thanks a lot…