跳到正文

个人记录

CPP

huhaoteng123约 1 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2026年3月2日
篇幅
约 1 分钟

版本

  1. v1当前
C++
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e6+7;
long long a[maxn],b[maxn];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int n;cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		b[a[i]]+=a[i];
	}
	for(int i=1000000;i>=0;i--){
		b[i]+=b[i+1];
	}
	for(int i=1;i<=n;i++){
		cout<<b[a[i]+1]<<" ";
	}
	return 0;
}

原文