此题太水!
代码:
1 #include<iostream> 2 #include<ctime> 3 #include<fstream> 4 #include <algorithm> 5 using namespace std; 6 int main() 7 { 8 clock_t start=clock(); 9 ifstream in("test.txt"); 10 int n;in>>n; 11 int i,j; 12 int *arr=new int[n]; 13 int sum=0; 14 for(i=0;i<n;i++) 15 { 16 in>>arr[i]; 17 sum+=arr[i]; 18 } 19 //目的找最大的组数,不用排序找出最大值也行,此题太水 20 sort(arr,arr+n); 21 if(arr[n-1]>sum/2) 22 cout<<"No"<<endl; 23 else 24 cout<<"Yse"<<endl; 25 clock_t end=clock(); 26 cout<<"Running Time: "<<(double)(end-start)/CLOCKS_PER_SEC<<endl; 27 return 0; 28 }