-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathA.kt
46 lines (34 loc) · 1.07 KB
/
A.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import java.lang.AssertionError
private val input = System.`in`.bufferedReader()
private val output = StringBuilder()
private fun readLn() = input.readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readDouble() = readLn().toDouble() // single double
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints
private fun readLongs() = readStrings().map { it.toLong() } // list of longs
private fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles
private fun myAssert(x: Boolean) {
if (!x) {
throw AssertionError()
}
}
private fun runCase() {
var n = readInt()
var a = readLongs()
a = a.sorted()
var ans: Long = 0L
for(i in 0 until n) {
ans = maxOf(ans, a[i] * (n - i))
}
output.append("$ans\n")
}
fun main(args: Array<String>) {
var t: Int = 1
t = readInt()
repeat(t) {
runCase()
}
print(output)
}