Tuesday, July 8, 2014

TopCoder High School SRM 37 Level one - 250 pt - Best Hotel solution

TopCoder High School SRM 37 Level one - 250 pt - Best Hotel statement: http://community.topcoder.com/stat?c=problem_statement&pm=7850&rd=10776

TopCoder High School SRM 37 Level one - 250 pt - Best Hotel editorial: http://community.topcoder.com/tc?module=Static&d1=hs&d2=match_editorials&d3=hs_srm37

TopCoder High School SRM 37 Level one - 250 pt - Best Hotel solution:

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

class BestHotel {
    public: int numberOfDisadvantageous(vector <int> p, vector <int> q) {
        int cnt=0, b[1005]={0};
        for(int i=0; i<p.size(); i++) {
            for(int j=0; j<p.size(); j++) {
                if(p[j]>p[i] && q[j]<=q[i] && b[j]==0) cnt++, b[j]=1;
                else if(p[j]==p[i] && q[j]<q[i] && b[j]==0) cnt++, b[j]=1;
            }
        }
        return cnt;
    }
};


No comments:

Post a Comment