hello大佬们,wa了T_T,求神犇们指导
  • 板块P4995 跳跳!
  • 楼主sqz11111
  • 当前回复0
  • 已保存回复0
  • 发布时间2024/3/10 13:45
  • 上次更新2024/3/10 16:05:55
查看原帖
hello大佬们,wa了T_T,求神犇们指导
995960
sqz11111楼主2024/3/10 13:45
#include<bits/stdc++.h>
#define int long long
using namespace std;
const string el="\n";

int n,sum=0;
vector<int> h;

int f(int h1,int h2){
	return (max(h1,h2)-min(h1,h2))*(max(h1,h2)-min(h1,h2));
}

signed main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin>>n;
	h.push_back(0);
	for(int i=0;i<n;i++){
		int inp;
		cin>>inp;
		h.push_back(inp);
	}
	sort(h.begin(),h.end());
	int l=n,r=0;
	for(int i=0;i<n;i++){
		sum+=f(h[l],h[r]);
		l--,r++;
	}
	cout<<sum;	
	return 0;
}
2024/3/10 13:45
加载中...