My first solved-problem on Codeforces.
It's really an easy problem.
As we know, if you want to make the a and b as small as possible, they must only contain digits 0 and 1.
So, we have the thinking in the following:
- if the digit of x[i] is 2: we try to make a[i] and b[i] both 1.
- if the digit of x[i] is 0: we try to make a[i] and b[i] both 0.
- if the digit of x[i] is 1: either a[i] or b[i] would be 1. We'll make a[i] 1 because it is no difference if we make b[i] 1.
However, if we make a[i] 1, the number a must be larger than b as a fact.
So, we would not want to make array a still bigger. So after we make a[i] 1, we have different thinking:
- if the digit of x[i] is 2: we make a[i] 0 and b[i] 2.
- if the digit of x[i] is 0: we make a[i] and b[i] both 0.
- if the digit of x[i] is 1: we make a[i] 0 and b[i] 1.
That's all. We'll discover that after we make a[i] 1, a does not increase anymore, but b is increasing, however it will never be bigger than a.
Thanks for reading, hope that'll help you!
Auto comment: topic has been updated by pengyule (previous revision, new revision, compare).