Submission #2184

# Submission time Handle Problem Language Result Execution time Memory
2184 2013-07-20T07:34:41 Z jwvg0425 지우개 (GA4_eraser) C++
100 / 100
24 ms 3620 KB
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<vector>
using namespace std;

#define MOD 1000000007
int n,r[100005];
long long int a[100005];
long long int v[100005],s[100005];

int main()
{
	int i,j,k,t=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%lld",&a[i]);
	sort(&a[0],&a[n]);
	s[0]=a[0];
	r[0]=1;
	for(i=1;i<n;i++)s[i]=s[i-1]+a[i];
	for(i=0;i<n;i++)
	{
		for(j=r[i];;j++)
		{
			if(a[j]!=a[i])
			{
				r[i]=r[i+1]=j;
				break;
			}
		}
	}
	for(j=n-1;j>0;j--)
	{
		k=r[j];
		if(k<n)
		{
			v[j]=(v[j+1]+(s[n-1]-s[k-1])*(long long int)a[j])%MOD;
		}
	}
	for(i=0;i<n-2;i++)
	{
		if(r[i]<n)
		{
			t=(t+v[r[i]]*(long long int)a[i])%MOD;
		}
	}
	printf("%lld",t);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 3620 KB Output is correct
2 Correct 0 ms 3620 KB Output is correct
3 Correct 0 ms 3620 KB Output is correct
4 Correct 0 ms 3620 KB Output is correct
5 Correct 0 ms 3620 KB Output is correct
6 Correct 0 ms 3620 KB Output is correct
7 Correct 0 ms 3620 KB Output is correct
8 Correct 0 ms 3620 KB Output is correct
9 Correct 0 ms 3620 KB Output is correct
10 Correct 0 ms 3620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 3620 KB Output is correct
2 Correct 0 ms 3620 KB Output is correct
3 Correct 0 ms 3620 KB Output is correct
4 Correct 0 ms 3620 KB Output is correct
5 Correct 0 ms 3620 KB Output is correct
6 Correct 0 ms 3620 KB Output is correct
7 Correct 0 ms 3620 KB Output is correct
8 Correct 0 ms 3620 KB Output is correct
9 Correct 0 ms 3620 KB Output is correct
10 Correct 0 ms 3620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 3620 KB Output is correct
2 Correct 0 ms 3620 KB Output is correct
3 Correct 0 ms 3620 KB Output is correct
4 Correct 0 ms 3620 KB Output is correct
5 Correct 0 ms 3620 KB Output is correct
6 Correct 0 ms 3620 KB Output is correct
7 Correct 0 ms 3620 KB Output is correct
8 Correct 0 ms 3620 KB Output is correct
9 Correct 0 ms 3620 KB Output is correct
10 Correct 0 ms 3620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 3620 KB Output is correct
2 Correct 0 ms 3620 KB Output is correct
3 Correct 0 ms 3620 KB Output is correct
4 Correct 0 ms 3620 KB Output is correct
5 Correct 0 ms 3620 KB Output is correct
6 Correct 0 ms 3620 KB Output is correct
7 Correct 0 ms 3620 KB Output is correct
8 Correct 0 ms 3620 KB Output is correct
9 Correct 0 ms 3620 KB Output is correct
10 Correct 0 ms 3620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 3620 KB Output is correct
2 Correct 3 ms 3620 KB Output is correct
3 Correct 2 ms 3620 KB Output is correct
4 Correct 13 ms 3620 KB Output is correct
5 Correct 0 ms 3620 KB Output is correct
6 Correct 12 ms 3620 KB Output is correct
7 Correct 6 ms 3620 KB Output is correct
8 Correct 24 ms 3620 KB Output is correct
9 Correct 15 ms 3620 KB Output is correct
10 Correct 19 ms 3620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 3620 KB Output is correct
2 Correct 0 ms 3620 KB Output is correct
3 Correct 20 ms 3620 KB Output is correct
4 Correct 4 ms 3620 KB Output is correct
5 Correct 19 ms 3620 KB Output is correct
6 Correct 3 ms 3620 KB Output is correct
7 Correct 17 ms 3620 KB Output is correct
8 Correct 14 ms 3620 KB Output is correct
9 Correct 22 ms 3620 KB Output is correct
10 Correct 15 ms 3620 KB Output is correct