1125 Chain the Ropes

英文版题目:https://pintia.cn/problem-sets/994805342720868352/problems/994805350316752896

中文版题目:https://pintia.cn/problem-sets/994805260223102976/problems/994805264706813952

 1 #include<iostream>
 2 #include<vector>
 3 #include<cmath> 
 4 #include<algorithm>
 5 using namespace std;
 6 
 7 int main(){
 8     int n;
 9     cin>>n;
10     vector<double> v(n);
11     for(int i = 0; i < n;++i) cin>>v[i];
12     sort(v.begin(),v.end());
13     int len = v[0];
14     for(int i = 1; i < v.size();++i)
15         len = (len+v[i])/2;
16     cout<<round(len);
17     return 0;
18 }

 

posted @ 2020-03-18 16:56  tangq123  阅读(147)  评论(0)    收藏  举报