Comments

main diagonal?

for all cells except the both diagonals, doesn't it?

you have to use files instead of standart input\output

yes, i know it, i just didn't care about it, because got ac on pretests=)

it is not the big problem, i think.

http://codeforces.me/contest/254/submission/2742493 — just initializing vector with 5001 element give stable ac=)

http://codeforces.me/contest/254/submission/2742524 — or using ArrayList, like you.

no=) vice versa.

9th test was pretest, firstly pretest got ac, but after contest it got tle. I could easily optimise it a bit on contest to get 100% AC, but it didn't fails from the beginning.

+1

when sum%n==0, we can get n numbers, which will be equal to average. when sum%n>0, we can get n-1 numbers, which will be equal to average, and 1, which will be average+sum%n=)

+5
1) n times 1

2) n-1 times 2 (pairs with most beautiful)

3) n-2 times 3 (two most beautiful with others)
...
k) n-k+1 times k (k-1 most beautiful with others)
...
n) all of them
On Aksenov239 → Codeforces Round #118, 14 years ago
0

I understood "A" from the very beginning. Also, didn't see any problem with description in "C". Seems that problems were with translation=)