Max Triangle
You have $N$ sticks of length $1, 2, ..., N$ respectively. Can you make a non-degenerate triangle$^{\dagger}$ with some $3$ sticks out of these $N$ sticks? Find the maximum possible perimeter$^{\ddagger}$ of a triangle you can make, or print $-1$ if not possible. --- $^{\dagger}$ You can make a non-degenerate triangle with sticks of sizes $A$, $B$ and $C$ if and only if $2 \cdot \max(A, B, C) <
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start