SRM 378 DIV1 Easy - TrueStatements

問題


http://community.topcoder.com/stat?c=problem_statement&pm=8390&rd=10798

解き方


正しいことを言っている人数を0〜50までのすべてについて調べ、
矛盾しないもののうち最大の人数が答えになる。

コード


class TrueStatements {

public: int numberTrue(vector<int> statements) {
int n=statements.size();

int ret=-1;
for(int i=0;i<=50;i++){
int cnt=0;
FORE(j,0,n)if(i==statements[j])cnt++;
if(i==cnt)ret=i;
}

return ret;
}

};

Share this

Related Posts