73分求助!!本地运行无误
查看原帖
73分求助!!本地运行无误
339335
cougarmace楼主2023/3/11 22:36

wa了三个点QAQ 大佬求助QAQ
本地运行没有问题 和测试点的输出一样的

#include<iostream>
#include<queue>
using namespace std;
struct node
{
    int key,num;
    friend bool operator<(node a,node b){
        return (a.num<b.num);
    }friend bool operator>(node a,node b){
        return (a.num>b.num);
    }
};
int n,a,sum,ans;
priority_queue<node,vector<node>,greater<node> > q;
int main(){
	cin>>n;
    for(int i=1;i<=n;i++){
        node k;
        cin>>k.num;
        sum+=k.num;
        k.key=i;
        q.push(k);
    }
    while(!q.empty()){
        node f=q.top();
        q.pop();
        ans+=f.num*q.size();
        cout<<f.key<<' ';
    }
    printf("\n%.2f\n",ans*1.0/n);
	return 0;
}
2023/3/11 22:36
加载中...