답안 #2237

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
2237 2013-07-20T14:11:04 Z kriii 지우개 (GA4_eraser) C++
100 / 100
40 ms 3232 KB
#include <stdio.h>
#include <algorithm>
#define max_a 100100

const long long mod = 1000000007;
int N; long long a[max_a],b[max_a],c[max_a],d;

void add(long long &a, long long p)
{
	a += p;
	if (a >= mod) a -= mod;
}

void in(long long *t, int x, long long p)
{
	for (;x<max_a;x+=x&(-x)) add(t[x],p); 
}

long long out(long long *t, int x)
{
	long long r = 0;
	for (;x;x-=x&(-x)) add(r,t[x]);
	return r;
}

int main()
{
	int i;

	scanf ("%d",&N);
	for (i=0;i<N;i++) scanf ("%lld",&a[i]);
	std::sort(a,a+N);

	for (i=0;i<N;i++){
		in(b,a[i],a[i]);
		in(c,a[i],a[i]*out(b,a[i]-1)%mod);
		add(d,a[i]*out(c,a[i]-1)%mod);
	}

	printf ("%lld",d);

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 3232 KB Output is correct
2 Correct 0 ms 3232 KB Output is correct
3 Correct 0 ms 3232 KB Output is correct
4 Correct 0 ms 3232 KB Output is correct
5 Correct 0 ms 3232 KB Output is correct
6 Correct 0 ms 3232 KB Output is correct
7 Correct 0 ms 3232 KB Output is correct
8 Correct 0 ms 3232 KB Output is correct
9 Correct 0 ms 3232 KB Output is correct
10 Correct 0 ms 3232 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 3232 KB Output is correct
2 Correct 0 ms 3232 KB Output is correct
3 Correct 0 ms 3232 KB Output is correct
4 Correct 0 ms 3232 KB Output is correct
5 Correct 0 ms 3232 KB Output is correct
6 Correct 0 ms 3232 KB Output is correct
7 Correct 0 ms 3232 KB Output is correct
8 Correct 0 ms 3232 KB Output is correct
9 Correct 0 ms 3232 KB Output is correct
10 Correct 0 ms 3232 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 3232 KB Output is correct
2 Correct 0 ms 3232 KB Output is correct
3 Correct 0 ms 3232 KB Output is correct
4 Correct 0 ms 3232 KB Output is correct
5 Correct 0 ms 3232 KB Output is correct
6 Correct 0 ms 3232 KB Output is correct
7 Correct 0 ms 3232 KB Output is correct
8 Correct 0 ms 3232 KB Output is correct
9 Correct 0 ms 3232 KB Output is correct
10 Correct 0 ms 3232 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 3232 KB Output is correct
2 Correct 0 ms 3232 KB Output is correct
3 Correct 0 ms 3232 KB Output is correct
4 Correct 0 ms 3232 KB Output is correct
5 Correct 0 ms 3232 KB Output is correct
6 Correct 0 ms 3232 KB Output is correct
7 Correct 0 ms 3232 KB Output is correct
8 Correct 0 ms 3232 KB Output is correct
9 Correct 0 ms 3232 KB Output is correct
10 Correct 0 ms 3232 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 3232 KB Output is correct
2 Correct 7 ms 3232 KB Output is correct
3 Correct 7 ms 3232 KB Output is correct
4 Correct 27 ms 3232 KB Output is correct
5 Correct 0 ms 3232 KB Output is correct
6 Correct 23 ms 3232 KB Output is correct
7 Correct 10 ms 3232 KB Output is correct
8 Correct 40 ms 3232 KB Output is correct
9 Correct 25 ms 3232 KB Output is correct
10 Correct 35 ms 3232 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 34 ms 3232 KB Output is correct
2 Correct 4 ms 3232 KB Output is correct
3 Correct 38 ms 3232 KB Output is correct
4 Correct 6 ms 3232 KB Output is correct
5 Correct 37 ms 3232 KB Output is correct
6 Correct 6 ms 3232 KB Output is correct
7 Correct 30 ms 3232 KB Output is correct
8 Correct 29 ms 3232 KB Output is correct
9 Correct 39 ms 3232 KB Output is correct
10 Correct 24 ms 3232 KB Output is correct