Advertisement
aslam_node

Untitled

May 25th, 2022
1,125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 0.71 KB | None | 0 0
  1.  
  2. import java.util.*
  3.  
  4. fun main() {
  5.     val reader = Scanner(System.`in`)
  6.     var testCases: Int = reader.nextInt()
  7.     var flag=false
  8.     while (testCases > 0) {
  9.         val arrayInt = IntArray(reader.nextInt())
  10.         for (item in arrayInt.indices)
  11.             arrayInt[item] = reader.nextInt()
  12.         for (i in arrayInt) {
  13.             val bigNumberArray = arrayInt.filter { it > i }.distinct()
  14.             val smallNumberArray = arrayInt.filter { it < i }.distinct()
  15.             flag = bigNumberArray.size >= 2 || smallNumberArray.size >= 2
  16.  
  17.         }
  18.         if (flag){
  19.             println("YES")
  20.             arrayInt.forEach { print("$it ") }
  21.         } else println("NO")
  22.         testCases--
  23.     }
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement