求助大佬,样例全过但是RE
  • 板块P4995 跳跳!
  • 楼主wdy1028
  • 当前回复2
  • 已保存回复2
  • 发布时间2021/6/26 13:53
  • 上次更新2023/11/4 21:27:56
查看原帖
求助大佬,样例全过但是RE
523541
wdy1028楼主2021/6/26 13:53
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#define maxn 500
using namespace std;
int n,a[maxn],sum,temp,temp2,b[maxn];
int main()
{
	scanf("%d",&n);
	for(int i = 1;i <= n;i++)
	{
		scanf("%d",&a[i]);
		b[i] = a[i];
	}
	a[0] = 0;
	for(int i = 1;i <= n;i++)
	{
		temp = a[i] - a[i-1];
		temp2 = i;
		for(int j = 1;j <= n;j++)
		{
			if(a[j] - a[j-1] > temp)
			{
				temp = a[j] - a[j-1];
				temp2 = a[j];
			}
		}
		sum += pow((b[temp2] - b[temp2-1]),2);
		a[temp2] = 0;
		temp2 = 0;
		temp = 0;	
	}
	printf("%d",sum);
	return 0;				
}
2021/6/26 13:53
加载中...