Solution:
We have a1+a2+⋯+a100≤200, so
a12+a22+⋯+a1002≤(100−a2)2+a22+a32+⋯+a1002=1002−200a2+2a22+a32+⋯+a1002≤1002−(a1+a2+⋯+a100)a2+2a22+a32+⋯+a1002=1002+(a22−a1a2)+(a32−a3a2)+(a42−a4a2)+⋯+(a1002−a100a2)=1002+(a2−a1)a2+(a3−a2)a3+(a4−a2)a4+⋯+(a100−a2)a100
Since a1≥a2≥⋯≥a100≥0, none of the terms (ai−aj)ai is positive. Thus a12+a22+⋯+a1002≤10,000 with equality holding if and only if
a1=100−a2 and a1+a2+⋯+a100=200
and each of the products
(a2−a1)a2,(a3−a2)a3,(a4−a2)a4,⋯,(a100−a2)a100
equals zero. Since a1≥a2≥a3≥⋯≥a100≥0, the last condition holds if and only if for some i≥1 we have a1=a2=⋯=ai and ai+1=⋯=a100=0. If i=1, then we get the solution 100,0,0,…,0. If i≥2, then from a1+a2=100, we get that i=4 and the second optimal solution 50,50,50,50,0,0,…,0.