Yes eventually you have to do that.
There are two bugs in your code. At first it looks all good to me. But after spending some hours on your code, I came to know about bugs. Guess what, fixing those two bugs gave me AC. So here it goes.
Comment from Mohit Gurumukhani
Looking this problem from DP point of view is quite interesting. I tried solving way Mohit has mentioned in his comment. But got WAs. I think I'm missing some clue while calculating backward segment.
Any help would be appreciated.
#!/usr/bin/python3def algo2():# inputsn = int(input())A = list(map(int, input().split()))B = list(map(int, input().split()))# Forward Segment i<=k segment finishing at indexDPF = [None]*nDPF[0] = A[0] # Base caseDPF[1] = max(A[1], A[0]+A[1])for k in range(2,n):DPF[k] = max(A[k], DPF[k-1]-A[k-1]+A[k]+B[k-1])#print(DPF)
Your code is correct. I think it's something to do with version of java they are using. That's why it's not getting AC. The version of python is also outdated. Whenever I had to submit problem on this site, I had to switch to older version. That's unfortunate.
I tried submitting your code on Codechef , it got AC. hurrah. So time to move on.
On line 124: you are printing one blank line before your intended result.
There is a option to post a code, use that. Otherwise it's all messy.
Good enough.
One suggestion since floor is an inbuilt function, better not to use it as a variable name. Though it is not giving any problem, still it would be good practice to do so.
Your code has too many print statement. Only print final winner with lead.
A big blunder on problem statement. It says that you have to print next permutation lexicographically. Got some WAs on first attempt. I was debugging my code whole this time. But the moment I changed my output to integer order. It got accepted. So output should actually be integer order.
For e.g.
'45' < '5' in lexicographic order
45 > 5 in Integer order