Hatena::Grouptopcoder

TopCoderの問題を解く

解いた問題の一覧表

2009-08-08

Workshop

| 19:29

問題文

作れる三角形の数を数える。

267.09/300 - 00:10:38

class Workshop {
    public:
        int pictureFrames(vector <int> pieces) {
            int result = 0;
            sort(pieces.begin(), pieces.end());
            const int size = pieces.size();
            for (int i = 0; i < size-2; i++) {
                for (int j = i+1; j < size-1; j++) {
                    for (int k = j+1; k < size; k++) {
                        if (pieces[i]<pieces[j]+pieces[k] &&
                                pieces[j]<pieces[i]+pieces[k] &&
                                pieces[k]<pieces[i]+pieces[j])
                            result++;
                    }
                }
            }
            return result;
        }
};

ewnfzgewnfzg2011/02/28 00:358HHlV6 <a href="http://nfypkepkeych.com/">nfypkepkeych</a>, [url=http://azgnisbcmhab.com/]azgnisbcmhab[/url], [link=http://jedmlehhrowo.com/]jedmlehhrowo[/link], http://pqvizwthqdkq.com/