topcoder被Appirio收购了
好久没做tc,这个题目挺简单。就是Arena里面看不到图片,只能去tc网站上找题目。http://community.topcoder.com/stat?c=problem_statement&pm=12746
#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[];
class TheTree {
public:
int maximumDiameter(vector <int> cnt) {
int D = cnt.size(), i, j;
int ans = , sum; for(i = ; i < D; ++i) {
for(j = i; j < D; ++j) tmp[j] = cnt[j];
sum = ;
for(j = i; j < D; ++j) {
if(tmp[j] != ) {
tmp[j]--;
sum++;
} else break;
}
for(j = i; j < D; ++j) {
if(tmp[j] != ) {
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!