Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

Help with understanding solution for D. Handshakes

Правка en2, от oleksg, 2021-08-24 01:10:08

Here is the problem link https://codeforces.me/contest/534/problem/D Basically, the problem boils down to finding a correct rearrangement of some numbers such that each next number is the previous number + 1 — 3m where m is some non-negative integer, and you have to start with 0. The solution is to always pick the biggest number possible, (so if you are currently on x, you try x + 1, then x — 2, then x — 5, etc...). Why does this solution work?

Теги #greedy, #help, # solution

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en3 Английский oleksg 2021-08-24 01:27:33 20 Tiny change: 'hy does this solution work?' -> 'hy does the greedy method work?'
en2 Английский oleksg 2021-08-24 01:10:08 9
en1 Английский oleksg 2021-08-24 01:09:19 513 Initial revision (published)