Programming Club IITM
Hey guys, I am Mantra (CF ID: Mantra7). In this video I have explained the solution to Problems D from the Codeforces Round #794 Div 2.
You can check out Solution for A,B and C in this video: https://youtu.be/0HTkyWnswv0
If you have any queries please put them in the comments. Make sure you like and subscribe : )
Youtuber
Consistency op
I forgot to mention one thing in the video. ab and ba vectors need to be sorted in increasing order.
The reason is that if we try to make BA from strings in ab then we would like to use as minimum number of strings as possible, because we are losing one potential AB in each string that we use to make BA.
So sorting will make sure that smaller strings are used in making AB and larger strings(thus less number) will may be used in making BA.
I'm a bit confused about the sorting part. Because we make BA from strings in ab only after all the AB's have exhausted, as first we're checking that if we can make AB.