Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
hibridge#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator