求大佬帮帮看看哪里错了-
  • 板块P4995 跳跳!
  • 楼主kiribati
  • 当前回复1
  • 已保存回复1
  • 发布时间2021/3/28 20:34
  • 上次更新2023/11/5 01:25:30
查看原帖
求大佬帮帮看看哪里错了-
474128
kiribati楼主2021/3/28 20:34
#include<iostream>
#include<stdio.h>
#include<queue>
using namespace std;

typedef unsigned long long ull;
ull res;
int n;

int main()
{
  priority_queue<int> dheap;
  priority_queue<int,vector<int>,greater<int> > xheap;
  scanf("%d",&n);
  xheap.push(0);
  for(int i = 1;i <= n;i++) 
  {
    int x;
    scanf("%d",&x);
    
    dheap.push(x);
    xheap.push(x);
  }
  
  int t = 0;
  
  while(t <= n)
  {
    res+= (dheap.top() - xheap.top()) * (dheap.top() - xheap.top());
    if(!t % 2) xheap.pop();
    else dheap.pop();
    t++;
  }
  
  printf("%lld",res);
  
  return 0;
}
2021/3/28 20:34
加载中...