首页 > 学院 > 开发设计 > 正文

1125. Chain the Ropes (25)

2019-11-06 07:29:19
字体:
来源:转载
供稿:网友

考试的时候英语读了半天,也是很简单题,从小到大排序,然后依次合并,最后即是结果(小于结果的最大整数)

#include<iostream>#include<vector>#include<algorithm>using namespace std;int main(){ int N; cin >> N; vector<double> all(N); for (int t = 0;t < N;t++) cin >> all[t]; sort(all.begin(), all.end()); double re = all[0]; for (int t = 1;t < N;t++) re = (re + all[t]) / 2; PRintf("%d/n", (int)re);}
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表