Submission #10514596
				
			
			
			Source Code Expand
			#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
const int N=100000;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u];i;i=sq[i].nxt)
#define fir first
#define sec second
#define mp make_pair
#define pb push_back
#define maxd 998244353
#define eps 1e-8
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}
namespace My_Math{
	#define N 100000
	int fac[N+100],invfac[N+100];
	int add(int x,int y) {return x+y>=maxd?x+y-maxd:x+y;}
	int dec(int x,int y) {return x<y?x-y+maxd:x-y;}
	int mul(int x,int y) {return 1ll*x*y%maxd;}
	ll qpow(ll x,int y)
	{
		ll ans=1;
		while (y)
		{
			if (y&1) ans=mul(ans,x);
			x=mul(x,x);y>>=1;
		}
		return ans;
	}
	int inv(int x) {return qpow(x,maxd-2);}
	int C(int n,int m)
	{
		if ((n<m) || (n<0) || (m<0)) return 0;
		return mul(mul(fac[n],invfac[m]),invfac[n-m]);
	}
	int math_init()
	{
		fac[0]=invfac[0]=1;
		rep(i,1,N) fac[i]=mul(fac[i-1],i);
		invfac[N]=inv(fac[N]);
		per(i,N-1,1) invfac[i]=mul(invfac[i+1],i+1);
	}
	#undef N
}
using namespace My_Math;
int n;
ll ans[100100];
pii a[100100];
int main()
{
	n=read();
	rep(i,1,n) 
	{
		a[i].fir=read();a[i].sec=i;
	}
	sort(a+1,a+1+n);
	reverse(a+1,a+1+n);
	int mn=n+1;
	rep(i,1,n)
	{
		mn=min(mn,a[i].sec);
		if (a[i].fir!=a[i+1].fir) ans[mn]+=1ll*(a[i].fir-a[i+1].fir)*i;
	}
	rep(i,1,n) printf("%lld\n",ans[i]);
	return 0;
}
			
				Submission Info
				
			
			
			
				
					| Submission Time |  | 
				
					| Task | E - Frequency | 
				
					| User | decodetalker | 
				
					| Language | C++14 (GCC 5.4.1) | 
				
					| Score | 700 | 
				
					| Code Size | 1991 Byte | 
				
					| Status | AC | 
				
					
						| Exec Time | 23 ms | 
					
						| Memory | 2688 KiB | 
				
			
Judge Result
				
					
							
								| Set Name | Sample | All | 
							
								| Score / Max Score | 0 / 0 | 700 / 700 | 
							
								| Status |  |  | 
						
 
				
					
						
						
							| Set Name | Test Cases | 
						
						
						
							
								| Sample | 00_example_01.txt, 00_example_02.txt | 
						
							
								| All | 00_example_01.txt, 00_example_02.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt | 
						
						
					
							
							
								| Case Name | Status | Exec Time | Memory | 
							
							
							
							
								| 00_example_01.txt | AC | 1 ms | 256 KiB | 
							
							
								| 00_example_02.txt | AC | 1 ms | 256 KiB | 
							
							
								| 01.txt | AC | 1 ms | 256 KiB | 
							
							
								| 02.txt | AC | 3 ms | 256 KiB | 
							
							
								| 03.txt | AC | 1 ms | 256 KiB | 
							
							
								| 04.txt | AC | 1 ms | 256 KiB | 
							
							
								| 05.txt | AC | 1 ms | 256 KiB | 
							
							
								| 06.txt | AC | 1 ms | 256 KiB | 
							
							
								| 07.txt | AC | 1 ms | 256 KiB | 
							
							
								| 08.txt | AC | 1 ms | 256 KiB | 
							
							
								| 09.txt | AC | 3 ms | 384 KiB | 
							
							
								| 10.txt | AC | 1 ms | 256 KiB | 
							
							
								| 11.txt | AC | 22 ms | 1280 KiB | 
							
							
								| 12.txt | AC | 23 ms | 1280 KiB | 
							
							
								| 13.txt | AC | 23 ms | 1280 KiB | 
							
							
								| 14.txt | AC | 22 ms | 1280 KiB | 
							
							
								| 15.txt | AC | 22 ms | 1280 KiB | 
							
							
								| 16.txt | AC | 20 ms | 1280 KiB | 
							
							
								| 17.txt | AC | 20 ms | 2432 KiB | 
							
							
								| 18.txt | AC | 19 ms | 1280 KiB | 
							
							
								| 19.txt | AC | 14 ms | 1280 KiB | 
							
							
								| 20.txt | AC | 22 ms | 1280 KiB | 
							
							
								| 21.txt | AC | 1 ms | 256 KiB | 
							
							
								| 22.txt | AC | 1 ms | 256 KiB | 
							
							
								| 23.txt | AC | 1 ms | 256 KiB | 
							
							
								| 24.txt | AC | 2 ms | 384 KiB | 
							
							
								| 25.txt | AC | 1 ms | 256 KiB | 
							
							
								| 26.txt | AC | 1 ms | 256 KiB | 
							
							
								| 27.txt | AC | 1 ms | 256 KiB | 
							
							
								| 28.txt | AC | 20 ms | 2560 KiB | 
							
							
								| 29.txt | AC | 20 ms | 2560 KiB | 
							
							
								| 30.txt | AC | 21 ms | 2688 KiB | 
							
							
								| 31.txt | AC | 20 ms | 2560 KiB | 
							
							
								| 32.txt | AC | 20 ms | 2560 KiB | 
							
							
								| 33.txt | AC | 18 ms | 1280 KiB | 
							
							
								| 34.txt | AC | 18 ms | 1280 KiB | 
							
							
								| 35.txt | AC | 18 ms | 1280 KiB | 
							
							
								| 36.txt | AC | 18 ms | 1280 KiB | 
							
							
								| 37.txt | AC | 18 ms | 1280 KiB |