SRM 591 div1 275

   topcoder被Appirio收购了

  好久没做tc,这个题目挺简单。就是Arena里面看不到图片,只能去tc网站上找题目。http://community.topcoder.com/stat?c=problem_statement&pm=12746

SRM 591 div1 275
#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

 

你可能感兴趣的:(div)