답안 #9485

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
9485 2014-09-28T06:47:23 Z yukariko Uniting (kriii2_U) C
0 / 4
0 ms 1356 KB
#include <stdio.h>
//#include <windows.h>
#include <stdlib.h>
#include <string.h>


int compare(const void *a , const void *b);

int main()
{
	int N;
	int s[100001];
	long long cnt;
	long long sum;
	int i,j;
	
	cnt = 1;
	sum = 0;
	
	scanf("%d",&N);
	
	for(i=0;i<N;i++) scanf("%d",s+i);
	
	for(i=N;i>=2;i--)
	{
		cnt *= i*(i-1);
	}
	qsort(s , N , sizeof(s[0]) , compare);
	for(i=0;i<N-1;i++)
	{
		sum += s[i]*s[i+1];
		s[i+1] += s[i];	
	}
	
	cnt = cnt%1000000007;
	printf("%lld\n",sum);
	printf("%lld\n",cnt);
	//system("pause");
	return 0;
}


int compare(const void *a , const void *b){

        return strcmp( (char*)a , (char*)b );

}
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 1356 KB Output is partially correct
2 Partially correct 0 ms 1356 KB Output is partially correct
3 Runtime error 0 ms 1356 KB open (syscall #2) was called by the program (disallowed syscall)
4 Halted 0 ms 0 KB -