시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
2 초 | 1024 MB | 40 | 20 | 20 | 66.667% |
There’s no such thing as public opinion.
Jordan Ellenberg, American Mathematician
In K City lives n residents who want to build a connection network with each other. However, some residents want the network wires colored black while the others want the wires colored white. The opinion of resident i can be quantified as a number ai . If we build a network wire between residents i and j, the cost of this wire will be ai × aj.
The mayor of K City wants to build a network such that:
In other words, the network should be a tree.
You, the renowned mathematician of K City, want to know not only the minimum cost to build the network. In the name of confusion, you also want to know the maximum cost!
The first line begins with a number n indicating the number of residents. The second line contains n numbers a1, a2, . . . , an. The opinion of resident i is the quantified as ai.
Output two numbers separated by a blank in a line. The numbers are the minimum cost and the maximum cost to build the network, respectively. Since the absolute value of the costs may be extremely large, you have to modulo the answer with 109 + 7. Please note that the modulo of a number (defined by Donald Knuth) is a mod b = a − b⌊a/b⌋. The output number should be non-negetive.
10 -5 -10 -7 -7 -3 -1 -7 -5 -8 -6
58 490
10 -5 1 2 -2 -1 1 -5 5 -10 6
999999779 183
10 0 0 0 0 0 0 0 0 0 0
0 0
10 10 8 9 3 8 8 0 5 3 10
0 540
ICPC > Regionals > Asia Pacific > Taiwan > Taiwan Online Programming Contest > TOPC 2020 H번