답안 #9622

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
9622 2014-09-28T07:43:16 Z kkjjkk Uniting (kriii2_U) C++
0 / 4
0 ms 2456 KB
#include <algorithm>
#include <iostream>
#include <cstdio>
using namespace std;
long long h[100005];

int main()
{
    int n;
    scanf("%d", &n);
    for(int i = 0; i < n; i++) scanf("%lld", &h[i]);
    if(n == 1) printf("0\n");
    else if(n == 2) { printf("%lld\n", h[0] * h[1]); }
    else {
         sort(h, h + n);
         long long a = h[0] + h[1];
         long long b = h[0] * h[1];
         long long c, d, m = 1000000007;
         for(int i = 2; i < n; i++) {
              c = a + h[i];
              d = a * h[i]; //d %= ;
              a = c;
              b = ((b % m) + (d % m)) % m; b %= 1000000007;
         }
         printf("%lld\n", b);
    }
    printf("-1");
}
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 2456 KB Output is partially correct
2 Partially correct 0 ms 2456 KB Output is partially correct
3 Partially correct 0 ms 2456 KB Output is partially correct
4 Partially correct 0 ms 2456 KB Output is partially correct
5 Incorrect 0 ms 2456 KB Output isn't correct
6 Halted 0 ms 0 KB -