Monday, June 9, 2014

Topcoder High School SRM 10 250 pt - Level one - Fractile solution

Topcoder High School SRM 10 250 pt - Level one - Fractile statement: http://community.topcoder.com/stat?c=problem_statement&pm=6552&rd=10062

Topcoder High School SRM 10 250 pt - Level one - Fractile editorial: http://community.topcoder.com/tc?module=Static&d1=hs&d2=match_editorials&d3=hs_srm10

Topcoder High School SRM 10 250 pt - Level one - Fractile solution: 

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

class Fractile {
    public: int fractile(vector <int> x, int p) {
        sort(x.begin(), x.end());
        if(p>0) return x[ceil((double)x.size()*p/100)-1];
        else return x[0];
    }
};

No comments:

Post a Comment