line = await readline() let total = +line let res = [] while (total--) { line = await readline() let days = +line line = await readline() let nums = line.split(' ').map(Number) let count = 0 let max = -Infinity let sorted = [] for (let i = 0; i < nums.length; i++) { let index = sorted.indexOf(nums[i]) if (index == -1) { sorted.push(nums[i]) if (sorted.length == 1) { max = count continue } let j = sorted.length - 1 for (; j > 0; j--) { if (sorted[j] < sorted[j - 1]) { [sorted[j], sorted[j - 1]] = [sorted[j - 1], sorted[j]]; } else { break } } count = count + j - (sorted.length - 1 - j) } else { count = count + index - (sorted.length - 1 - index) } if (count > max) { max = count } } let str = max + ' ' + count res.push(str) } res.forEach((item) => console.log(item))
点赞 评论

相关推荐

10-05 11:11
海南大学 Java
投票
理想江南137:感觉挺真诚的 感觉可以试一试
点赞 评论 收藏
分享
尊嘟假嘟点击就送:加v细说,问题很大
点赞 评论 收藏
分享
牛客网
牛客企业服务