We'd like to thank you all for participating in the contest, and hope you enjoyed it. Hope to see you again soon!
Author: BitWizz
Since we want to minimize the number of win of our team, we would like to finish on $$$4th$$$ position. Now the problem reduces to finishing on the $$$1st$$$ position with remaining $$$N - 3$$$ teams. Since we can decide the net run-rate of teams, we would try to give equal wins to each team. There will be total $$$N - 3$$$ teams and $$${N - 3 \choose 2}$$$ matches, so if $$$N$$$ is even we can equally divide the wins and each team will win $$$(N - 4)/2$$$ matches and we would give our team the highest net run-rate. If $$$N$$$ is odd then we must give the extra win to our team, then the total wins is $$$(N - 3)/2$$$.
Time Complexity: $$$\mathcal{O}(1)$$$
#include <bits/stdc++.h>
using namespace std;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define int int64_t
void solve() {
int n; cin >> n;
if (n % 2 == 0) {
int m = (n - 4) / 2;
cout << m << '\n';
}
else {
int m = floor((n - 4) / 2) + 1;
cout << m << '\n';
}
}
signed main() {
fastio();
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int tc;
cin >> tc;
while (tc--)
solve();
return 0;
}




