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

1125. Chain the Ropes 解析

2019-11-06 06:39:20
字体:
来源:转载
供稿:网友

排序从小到大累加打结就好了~~~

#include <iostream>#include <algorithm>#define MAX 10010using namespace std;int rope[MAX];int n;int main() {	cin >> n;	for (int i = 0; i < n; i++) {		cin >> rope[i];	}	sort(rope, rope + n);	int max = rope[0];	int link = rope[0];	bool tag = false;	for (int i = 1; i < n; i++) {		link += rope[i];		link /= 2;	}	cout << link << endl;		return 0;}


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表