1125. Chain the Ropes (25)

来源:互联网 发布:ros系统 与 linux 编辑:程序博客网 时间:2024/06/10 18:33

1125. Chain the Ropes (25)

#include <iostream>#include <vector>#include <algorithm>using namespace std;int main(){    int n;    vector<double> v;    cin>>n;    while(n--)    {        double t;        cin>>t;        v.push_back(t);    }    sort(v.begin(),v.end(),greater<double>());    while(v.size()!=1)    {        double m,n;        m=v.back();        v.pop_back();        n=v.back();        v.pop_back();        v.push_back((m+n)/2);    }    cout<<(int)v[0];    return 0;}
原创粉丝点击