problem link :- https://codeforces.me/contest/1717/problem/C
submission link:- https://codeforces.me/contest/1717/submission/336098886
| # | User | Rating |
|---|---|---|
| 1 | jiangly | 3810 |
| 2 | Benq | 3676 |
| 3 | Kevin114514 | 3655 |
| 4 | maroonrk | 3463 |
| 5 | strapple | 3447 |
| 6 | Um_nik | 3387 |
| 7 | heuristica | 3322 |
| 8 | turmax | 3317 |
| 9 | tourist | 3307 |
| 10 | jiangbowen | 3291 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 156 |
| 2 | nik_exists | 150 |
| 2 | maspy | 150 |
| 4 | Um_nik | 142 |
| 5 | Errichto | 139 |
| 6 | adamant | 137 |
| 7 | AmShZ | 135 |
| 8 | BledDest | 132 |
| 8 | maroonrk | 132 |
| 10 | qwexd | 129 |
problem link :- https://codeforces.me/contest/1717/problem/C
submission link:- https://codeforces.me/contest/1717/submission/336098886
| Name |
|---|



One thing wrong is how you wrote your code. Always try to keep it simple and easy to debug even if you are implementing a hard implementation problem. Maybe your idea gives a good answer, but it is just very complicated to implement and it's very probable that you wrote a bug there.
Always keep the idea simple when it's possible.
I think it's hard, even me knowing this, sometimes I just over complicate the solution or write bad code.
You are trying to simulate the whole operation which is not needed here, only the necessary checks are required to ensure that array formation will be possible, and for that only two check are required, first is that if any a[i]>b[i] then it will always be false because we cannot decrease any a[i] element to make it equal to b[i]. second condition if a[i]!=b[i] and b[i]-b[i+1]>=2, this condition will also make array formation impossible. as we can only increase an a[i] to a[i+1]+1 at max. so either a[i] should be equal to b[i] but if its not. we can not increase it to b[i] without violating the condition for b[i+1]. example :- a = [1, 1], b = [6, 4], first operation on a, [1, 2], second operation [3, 2], third operation [3, 4], fourth operation [5, 4]. note that here since difference in b[i]-b[i+1]>=2 and a[i]!=bi, therefore we can never satisfy b[i] condition, but if we say lets increase b[i+1] to increase b[i]. [5, 5] then [6, 5]. now you see b[i+1] condition is false and will never be possible because no reduce operation is allowed.