CodeForces 990B
Posted daybreaking
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CodeForces 990B相关的知识,希望对你有一定的参考价值。
You have a Petri dish with bacteria and you are preparing to dive into the harsh micro-world. But, unfortunately, you don‘t have any microscope nearby, so you can‘t watch them.
You know that you have nn bacteria in the Petri dish and size of the ii-th bacteria is aiai. Also you know intergalactic positive integer constant KK.
The ii-th bacteria can swallow the jj-th bacteria if and only if ai>ajai>aj and ai≤aj+Kai≤aj+K. The jj-th bacteria disappear, but the ii-th bacteria doesn‘t change its size. The bacteria can perform multiple swallows. On each swallow operation any bacteria ii can swallow any bacteria jj if ai>ajai>aj and ai≤aj+Kai≤aj+K. The swallow operations go one after another.
For example, the sequence of bacteria sizes a=[101,53,42,102,101,55,54]a=[101,53,42,102,101,55,54] and K=1K=1. The one of possible sequences of swallows is: [101,53,42,102,101???,55,54][101,53,42,102,101_,55,54] →→ [101,53??,42,102,55,54][101,53_,42,102,55,54] →→ [101???,42,102,55,54][101_,42,102,55,54] →→ [42,102,55,54??][42,102,55,54_] →→ [42,102,55]