題目沒讀懂,剛開始都不知道他在說些什麼。。。ios
簡而言之就是給出一堆繩子,練成一條;spa
沒兩兩段繩子練成環,串在一塊兒,以後仍舊視爲一串繩子,下次跟別的單獨繩子鏈接的時候仍需對摺;code
因此能夠看出,越長的繩子在前面越對摺越吃虧,因此應該進行排序,長的繩子放在後面進行鏈接;排序
#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; }