SRM 591 div1 275

   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[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!
View Code

 

posted @ 2013-09-21 10:32  AC_Von  阅读(340)  评论(0编辑  收藏  举报