Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

hibridge

Posted by hi_bridge at 2012-05-09 11:48:55 on Problem 1011
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <math.h>

using namespace std;

#define MAX 20


int f(int n,vector <int> wood)
{
    int max,sum=0;
    sort(wood.begin(),wood.end());
    max=wood.back();

    for(int i=0;i<n;++i)
        sum+=wood[i];

    while(sum>=max++)
    {
        if(sum/max==floor(sum/max))
             return max;
    }
    return  0;
}

int main()
{
    int i,n;
    vector <int> wood;
    while(cin>>n)
    {
        int item;
        for(i=0;i<n;++i)
        {
            cin>>item;
            wood.push_back(item);
        }
        cout<<f(n,wood);
    }
    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator