pat-1125

In fact, this question is a bit like Huffman tree 

#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	double a[n];
	fill(a,a+n,0);
	for(int i=0;i<n;i++){
		scanf("%lf",&a[i]);//输入double型就要%lf把scanf后面跟的东西弄对(注意) 
	}
	sort(a,a+n);
	for(int i=0;i<n-1;i++){
		
		a[i+1]=(a[i]+a[i+1])/2;
	}
	printf("%d",(int)a[n-1]);
	return 0;
}

to sum up

1. Didn’t find the smallest half—+the second smallest half<the third smallest, and I didn’t seriously think about this rule and directly violently arrange once every time and cause overtime

2. When entering double or other types, pay attention to what should be written after scanf and "" 

English

Find more questions about the hidden rules of this question. Stop using cin cout according to the question stem. 

Guess you like

Origin blog.csdn.net/m0_45359314/article/details/113064172