Submission #1990

# Submission time Handle Problem Language Result Execution time Memory
1990 2013-07-19T14:33:18 Z mh5664 지우개 (GA4_eraser) C++
100 / 100
25 ms 4012 KB
#include <stdio.h>
#include <algorithm>

using namespace std;

const int MAXN = 100000;
const long long int mod = 1000000007;

long long int data[MAXN + 1];
long long int data2[MAXN + 1];
long long int sum[MAXN + 1];
long long int sum2[MAXN + 1];
int main ()
{
	int n;

	scanf ("%d", &n);
	
	for (int i = 0; i < n; ++i)
	{
		scanf ("%lld", &data[i]);
	}

	sort (data, data + n);

	sum[0] = data[0];

	for (int i = 1; i < n; ++i)
	{
		sum[i] = (sum[i - 1] + data[i]) % mod;
		if (sum[i] < 0)
			sum[i] += mod;
	}
	for (int i = 0; i < n - 1; ++i)
	{
		if (data[i] == data[i + 1])
			continue;
		else
		{
			long long int r;
			int s;
			r = ((sum[n - 1] - sum[i]) * data[i]) % mod;
			if (r < 0)
				r += mod;
			s = i;
			while (s >= 0)
			{
				if (data[s] != data[i])
					break;
				data2[s] = r;
				--s;
			}
		}
	}

	sum2[0] = data2[0];
	for (int i = 1; i < n - 1; ++i)
	{
		sum2[i] = (sum2[i - 1] + data2[i]) % mod;
		if (sum2[i] < 0)
			sum2[i] += mod;
	}

	long long int sol = 0;
	for (int i = 0; i < n - 2; ++i)
	{
		if (data[i] == data[i + 1])
			continue;
		else
		{
			long long int r;
			int s;
			r = ((sum2[n - 2] - sum2[i]) * data[i]) % mod;
			if (r < 0)
				r += mod;
			s = i;
			while (s >= 0)
			{
				if (data[s] != data[i])
					break;
				sol = (sol + r) % mod;
				if (sol < 0)
					sol += mod;
				--s;
			}
		}
	}

	printf ("%lld", sol);
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 4012 KB Output is correct
2 Correct 0 ms 4012 KB Output is correct
3 Correct 0 ms 4012 KB Output is correct
4 Correct 0 ms 4012 KB Output is correct
5 Correct 0 ms 4012 KB Output is correct
6 Correct 0 ms 4012 KB Output is correct
7 Correct 0 ms 4012 KB Output is correct
8 Correct 0 ms 4012 KB Output is correct
9 Correct 0 ms 4012 KB Output is correct
10 Correct 0 ms 4012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 4012 KB Output is correct
2 Correct 0 ms 4012 KB Output is correct
3 Correct 0 ms 4012 KB Output is correct
4 Correct 0 ms 4012 KB Output is correct
5 Correct 0 ms 4012 KB Output is correct
6 Correct 0 ms 4012 KB Output is correct
7 Correct 0 ms 4012 KB Output is correct
8 Correct 0 ms 4012 KB Output is correct
9 Correct 0 ms 4012 KB Output is correct
10 Correct 0 ms 4012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 4012 KB Output is correct
2 Correct 0 ms 4012 KB Output is correct
3 Correct 0 ms 4012 KB Output is correct
4 Correct 0 ms 4012 KB Output is correct
5 Correct 0 ms 4012 KB Output is correct
6 Correct 0 ms 4012 KB Output is correct
7 Correct 0 ms 4012 KB Output is correct
8 Correct 0 ms 4012 KB Output is correct
9 Correct 0 ms 4012 KB Output is correct
10 Correct 0 ms 4012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 4012 KB Output is correct
2 Correct 0 ms 4012 KB Output is correct
3 Correct 0 ms 4012 KB Output is correct
4 Correct 0 ms 4012 KB Output is correct
5 Correct 0 ms 4012 KB Output is correct
6 Correct 0 ms 4012 KB Output is correct
7 Correct 0 ms 4012 KB Output is correct
8 Correct 0 ms 4012 KB Output is correct
9 Correct 0 ms 4012 KB Output is correct
10 Correct 0 ms 4012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 4012 KB Output is correct
2 Correct 2 ms 4012 KB Output is correct
3 Correct 1 ms 4012 KB Output is correct
4 Correct 16 ms 4012 KB Output is correct
5 Correct 0 ms 4012 KB Output is correct
6 Correct 14 ms 4012 KB Output is correct
7 Correct 3 ms 4012 KB Output is correct
8 Correct 25 ms 4012 KB Output is correct
9 Correct 15 ms 4012 KB Output is correct
10 Correct 20 ms 4012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 4012 KB Output is correct
2 Correct 1 ms 4012 KB Output is correct
3 Correct 21 ms 4012 KB Output is correct
4 Correct 4 ms 4012 KB Output is correct
5 Correct 21 ms 4012 KB Output is correct
6 Correct 3 ms 4012 KB Output is correct
7 Correct 15 ms 4012 KB Output is correct
8 Correct 17 ms 4012 KB Output is correct
9 Correct 24 ms 4012 KB Output is correct
10 Correct 18 ms 4012 KB Output is correct