Monday 26 September 2016

UVA 11875 - Brick Game

Problem Link:UVA 11875 - Brick Game
Hints:Array list টা sort করে মাঝের index টা নিতে হবে।
Code:
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long i,t,ar[20],m,j,mid;
    cin>>t;
    for(i=1;i<=t;i++)
    {
        cin>>m;
        for(j=0;j<m;j++)
            cin>>ar[j];
        sort(ar,ar+m);
        mid=(m+1)/2;
        cout<<"Case "<<i<<": "<<ar[mid-1]<<endl;
    }
    return 0;
}

2 comments:

  1. can be done easily by printing ara[n/2] where n/2 type casted to an integar

    ReplyDelete
  2. can be done easily by printing ara[n/2] where n/2 type casted to an integar

    ReplyDelete