Jul 8, 2018 at 2:01pm Jul 8, 2018 at 2:01pm UTC
Can anyone help me with this question ?
my approach was to find greatest character from the current char and find their difference but it gave me WA.Can anyone guide me here?
Last edited on Jul 8, 2018 at 2:02pm Jul 8, 2018 at 2:02pm UTC
Jul 8, 2018 at 6:15pm Jul 8, 2018 at 6:15pm UTC
Um
*What are you trying to do?
*What don't you understand?
*What have you tried so far?
*Where is your code?
It's hard really, to help you without the above..
Jul 8, 2018 at 6:17pm Jul 8, 2018 at 6:17pm UTC
Last edited on Jul 8, 2018 at 6:18pm Jul 8, 2018 at 6:18pm UTC
Jul 9, 2018 at 2:36am Jul 9, 2018 at 2:36am UTC
I have replaced the current char by the max char occuring after it and had a count of (curr - max).Heres the problem link
https://www.codechef.com/JULY18B/problems/NSA
Jul 9, 2018 at 1:12pm Jul 9, 2018 at 1:12pm UTC
Someone please help me with this problem !!
Jul 9, 2018 at 2:52pm Jul 9, 2018 at 2:52pm UTC
i have partially accepted solution for both NSA and NMNMX.
if anyone has fully accepted solution of any and wants partial of the other , DM me
Jul 11, 2018 at 4:20am Jul 11, 2018 at 4:20am UTC
@wasp
why are changing with maximum character occuring.
zzzzzzzzaaab
take this example
Jul 11, 2018 at 5:33am Jul 11, 2018 at 5:33am UTC
yes here i change every a to b to the answer is 3
Jul 11, 2018 at 5:41am Jul 11, 2018 at 5:41am UTC
Why are you changing all a's?You can only change 1 letter in the entire string...
Jul 11, 2018 at 6:05am Jul 11, 2018 at 6:05am UTC
I have come up with an O(n^2logn) approach but its still not good enough for 100pts :/
Jul 11, 2018 at 6:13am Jul 11, 2018 at 6:13am UTC
@honeybuzz can you share your algo PM me
Jul 11, 2018 at 8:00am Jul 11, 2018 at 8:00am UTC
@gear how can your solution be O(n) if it is brute force?I think you might be messing up the logic to reduce the complexity and hence are getting WA...Because using brute force to simply calculate the cost of the given string without even making any changes itself is O(n^2).
Jul 11, 2018 at 8:20am Jul 11, 2018 at 8:20am UTC
@vigilante
In abcd
bcd > a so count 3
then cd > b so count 3+2=5
then c>d so count 5+1=6
Jul 11, 2018 at 9:07am Jul 11, 2018 at 9:07am UTC
@Wasp actually my solution is just able to pass 1 test case of the last subtask...Hence even though its better than the brute force(since it passes only 3 cases), my solution passes just 1 more case...Moreover, the 2nd test case of the 2nd subtask still gave TLE...
Jul 11, 2018 at 10:34am Jul 11, 2018 at 10:34am UTC
@honeybuzz
what algo u use for clearing last subtask . how u reduce time complexity..
Jul 11, 2018 at 10:45am Jul 11, 2018 at 10:45am UTC
@ gear1
ur concept can give maximum value of answer x+y=25 .. thats always not true..
Jul 11, 2018 at 11:46am Jul 11, 2018 at 11:46am UTC
u can calculate next max element for every index....that can help
Jul 11, 2018 at 1:09pm Jul 11, 2018 at 1:09pm UTC
@hackr1
now check pm and now make your promise, give me the solution.
and don't worry i will not copy paste the solution .