topcoder被Appirio收购了
好久没做tc,这个题目挺简单。就是Arena里面看不到图片,只能去tc网站上找题目。http://community.topcoder.com/stat?c=problem_statement&pm=12746
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
#include <vector> #include <list> #include <map> #include <set> #include <queue> #include <deque> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <cmath> #include <cstdlib> #include <ctime> using namespace std; int tmp[55]; class TheTree { public: int maximumDiameter(vector <int> cnt) { int D = cnt.size(), i, j; int ans = 0, sum; for(i = 0; i < D; ++i) { for(j = i; j < D; ++j) tmp[j] = cnt[j]; sum = 0; for(j = i; j < D; ++j) { if(tmp[j] != 0) { tmp[j]--; sum++; } else break; } for(j = i; j < D; ++j) { if(tmp[j] != 0) { tmp[j]--; sum++; } else break; } printf("%d\n", sum); ans = max(ans, sum); } return ans; } }; <%:testing-code%> //Powered by KawigiEdit 2.1.8 (beta) modified by pivanof!