Submission #1936

# Submission time Handle Problem Language Result Execution time Memory
1936 2013-07-19T12:21:31 Z mh5664 지우개 (GA4_eraser) C++
0 / 100
21 ms 3676 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 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;
	}

	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;
			s = i;
			while (s >= 0)
			{
				if (data[s] != data[i])
					break;
				sum2[s] = r;
				--s;
			}
		}
	}

	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[i + 1] * data[i]) % mod;
			s = i;
			while (s >= 0)
			{
				if (data[s] != data[i])
					break;
				sol = (sol + r) % mod;
				--s;
			}
		}
	}

	printf ( "%d", sol);
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 3228 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 3228 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 3228 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 3228 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 3228 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 3676 KB Output isn't correct
2 Halted 0 ms 0 KB -