題目沒讀懂,剛開始都不知道他在說些什麼。。。
簡而言之就是給出一堆繩子,練成一條;
沒兩兩段繩子練成環,串在一起,之後仍舊視爲一串繩子,下次跟別的單獨繩子連接的時候仍需對摺;
所以可以看出,越長的繩子在前面越對摺越吃虧,所以應該進行排序,長的繩子放在後面進行連接;
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<vector>
#include<set>
#include<algorithm>
using namespace std;
using std::vector;
using std::set;
const int maxn=10100;
int lope[maxn]={0};
int main(){
int n;
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%d",&lope[i]);
}
sort(lope,lope+n);
int line=lope[0];
for(int i=1;i<n;i++){
line+=lope[i];
line/=2;
}
printf("%d",line);
system("pause");
return 0;
}