0w1

CFR 595 C. Warrior and Archer ( Ad hoc, Game )

Problem - C - Codeforces
I really enjoyed this problem, for it did not require much code, and the solution is actually simple despite the fact that it needs some creativity( seems like being able to solve ABC before 70 min will have placed one in the first 10 ).
First I thought about what is the objective of the first player ( who wants to make the final distance shortest possible ). I discovered he will only take from both sides towards the middle, because if he only took some in the middle, he would have actually enlarged the distance.
Then the objective of the second player ( who wants to make the final distance longest possible ), is to take as much middle ones as possible.
The number of rounds for each player is ( N - 2 ) / 2. The first player will be able to force the second player to play in any range he aims to, but the second player will always be able to take the leftmost and the rightmost of the range the first player had placed him to. So, the answer is the maximal difference in two positions that are ( N - 2 ) / 2 positions away.

void solve(){
    int N; cin >> N;
    vi P( N );
    for( int i = 0; i < N; ++i )
        cin >> P[ i ];
    sort( P.begin(), P.end() );
    int ans = 1e9;
    for( int i = 0; i + N / 2 < N; ++i )
        ans = min( ans, P[ i + N / 2 ] - P[ i ] );
    cout << ans << endl;
}