USACO Bronze, Promotion Counting

Hello, I need help understanding the solution for this problem:


#include <bits/stdc++.h>
using namespace std;

int main()
freopen(“”, “r”, stdin);
freopen(“promote.out”, “w”, stdout);
int bb, ba, sb, sa, gb, ga, pb, pa, ts, tg, tp;

cin >> bb >> ba >> sb >> sa >> gb >> ga >> pb >> pa;

tp = pa - pb;
tg = ga - gb + pa - pb;
ts = sa - sb + ga - gb + pa - pb;

cout << ts << "\n" << tg << "\n" << tp << endl;

return 0;


Why is it adding the promotions to platinum in the calculation for promotions to gold and the promotions to gold in the calculation for promotions to silver.

That is because people who promoted to silver have to pass bronze, and people who pass to gold have to pass bronze and silver, people who’s promoted to Plat have to pass gold, silver, and bronze,