社区讨论
为什么不对啊,,,,
P4995跳跳!参与者 3已保存回复 3
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 3 条
- 当前快照
- 1 份
- 快照标识符
- @mi7cgfwb
- 此快照首次捕获于
- 2025/11/20 19:24 4 个月前
- 此快照最后确认于
- 2025/11/20 19:24 4 个月前
CPP
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int n;
int h[301]={0};
int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++) scanf("%d",&h[i]);
sort(h+1,h+n+1);
int top=1,tail=n-1;
int ans=0;
ans+=h[n]*h[n];
while(top<=tail){
ans+=(h[tail+1]-h[top])*(h[tail+1]-h[top]);
ans+=(h[tail]-h[top])*(h[tail]-h[top]);
top++;tail--;
}
printf("%d",ans);
return 0;
}
当我只得了50分,又去找错误的时候,并没看看见什么错误,而且思想我看了一遍应该是对的,求大佬看一看,,,,,,
回复
共 3 条回复,欢迎继续交流。
正在加载回复...