Thursday, June 9, 2016

uva 10107 solution

Unknown
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
typedef unsigned long long llu;

int main()
{
    vector <llu>v;
    vector <llu>::iterator low,it;
    llu n;
    int t=1;
    while (scanf("%llu",&amp;n)!=EOF)
    {
        if (t==1) v.push_back(n);
        else
        {
            low=lower_bound(v.begin(),v.end(),n);
            v.insert(low,n);
        }
        if (t%2)
        {
            printf("%llu\n",v[t/2]);
        }
        else printf("%llu\n",(v[(t-1)/2]+v[(t+1)/2])/2);
        t++;
    }
    return 0;
}

Unknown

Studying at Shahjalal University of Science and Technology, Sylhet.

0 comments:

Post a Comment

Coprights @ 2016,