답안 #9288

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
9288 2014-09-28T05:23:36 Z altertain Uniting (kriii2_U) C++
0 / 4
0 ms 1676 KB
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cctype>
#include <cstring>
#include <queue>
#include <cassert>

using namespace std;

typedef long long LL;
typedef vector<string> VS;
typedef vector<int> VI;
typedef pair<int,int> PII;
typedef vector<PII> VPII;

#define MP make_pair
#define ST first
#define ND second
#define PB push_back
#define FOR(i,a,b) for( int i=(a); i<(b); ++i)
#define FORD(i,a,b) for( int i=(a); i>(b); --i)
#define REP(i,n) for(int i=0; i<(n); ++i)
#define ALL(X) (X).begin(),(X).end()
#define SZ(X) (int)(X).size()
#define FORE(it,X) for(__typeof((X).begin()) it=(X).begin(); it!=(X).end();++it)

#define M 1000000007

int n;

int main()
{
	cin>>n;
	priority_queue<int> pq;
	REP(i,n) {
		int a;
		scanf("%d",&a);
		pq.push(-a);
	}

	LL dp = 0;
	REP(i,n-1) {
		int a, b;
		a = pq.top(); pq.pop();
		b = pq.top(); pq.pop();
		dp = (dp+LL(a) * b) % M;

		pq.push(a+b);
	}

	cout<<dp<<endl<<0<<endl;

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 1676 KB Output is partially correct
2 Partially correct 0 ms 1676 KB Output is partially correct
3 Partially correct 0 ms 1676 KB Output is partially correct
4 Partially correct 0 ms 1676 KB Output is partially correct
5 Incorrect 0 ms 1676 KB Output isn't correct
6 Halted 0 ms 0 KB -