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

#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

typedef long long int ll;

ll mod=1e9+7;
ll a[300010];
ll c[300010];

ll tc,i,j,k,n,m;
string s,s1,s2;

map<ll,ll> mp;

int main(){
    //IOS

    cin>>tc;
    while(tc--){

            cin>>n;
            ll s=0;
            for(i=0;i<n;i++){
                cin>>a[i];
                s+=a[i];
            }

            ll avg=ceil(s/(double)n);

            ll all=n;
            ll days=n;

            for(i=0;i<n;i++)
                if(a[i]<avg){
                s-=a[i];
                a[i]=-1;
                all--;
                }

            avg=ceil(s/(double)all);

            for(i=0;i<n;i++)
                if(a[i]<avg && a[i]!=-1){
                s-=a[i];
                a[i]=-1;
                all--;
                }


            for(i=0;i<n;i++)
                if(a[i]!=-1)
                cout<<a[i]<<' ';

            cout<<endl;
    }

}
Copy
To-do List AshcoOoOdel
GNU G++17
415 ms
2.2 MB
Wrong Answer