蒟蒻求救大佬
  • 板块P4995 跳跳!
  • 楼主lucas_vio
  • 当前回复5
  • 已保存回复5
  • 发布时间2024/6/16 15:25
  • 上次更新2024/6/16 18:18:09
查看原帖
蒟蒻求救大佬
1043130
lucas_vio楼主2024/6/16 15:25
#include <bits/stdc++.h>
using namespace std;
int a[1000], b, ans;

int main() {
	cin >> b;
	for (int i = 0; i < b; i++) {
		cin >> a[i];
	}
	sort(a, a + b + 1);
	int x = 0, y = b;
	while (y > 1) {
		ans += pow(a[y] - a[x], 2);
		x++;
		ans += pow(a[x] - a[y], 2);
		y--;
	}
	cout << ans;
	return 0;
}
2024/6/16 15:25
加载中...