Please read the new rule regarding the restriction on the use of AI tools. ×

Help with understanding solution for D. Handshakes

Revision en1, by oleksg, 2021-08-24 01:09:19

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?

Tags #greedy, #help, # solution

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English oleksg 2021-08-24 01:27:33 20 Tiny change: 'hy does this solution work?' -> 'hy does the greedy method work?'
en2 English oleksg 2021-08-24 01:10:08 9
en1 English oleksg 2021-08-24 01:09:19 513 Initial revision (published)