Submission #19523254


Source Code Expand

Copy
from collections import Counter
N,K,*A = [int(x) for x in open(0).read().split()]

ans=0
mod=10**9+7
for i in range(N-1,-1,-1):
    t1=0
    for j in range(i-1,-1,-1):
        if A[i] < A[j]:
            t1+=1
    t2=0
    for j in range(N):
        if A[i] < A[j]:
            t2+=1
    ans+=t1*K + t2*((K*(K-1))//2)

print(ans%mod)

Submission Info

Submission Time
Task B - Kleene Inversion
User hythof
Language PyPy3 (7.3.0)
Score 300
Code Size 349 Byte
Status AC
Exec Time 114 ms
Memory 68688 KB

Judge Result

Set Name All Sample
Score / Max Score 300 / 300 0 / 0
Status
AC × 24
AC × 3
Set Name Test Cases
All sample_01, sample_02, sample_03, testcase_0, testcase_1, testcase_10, testcase_11, testcase_12, testcase_13, testcase_14, testcase_15, testcase_16, testcase_17, testcase_18, testcase_19, testcase_2, testcase_20, testcase_3, testcase_4, testcase_5, testcase_6, testcase_7, testcase_8, testcase_9
Sample sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
sample_01 AC 89 ms 64948 KB
sample_02 AC 59 ms 64660 KB
sample_03 AC 58 ms 64536 KB
testcase_0 AC 65 ms 68108 KB
testcase_1 AC 65 ms 68252 KB
testcase_10 AC 75 ms 68044 KB
testcase_11 AC 75 ms 68440 KB
testcase_12 AC 60 ms 65020 KB
testcase_13 AC 83 ms 68652 KB
testcase_14 AC 75 ms 68396 KB
testcase_15 AC 72 ms 68612 KB
testcase_16 AC 69 ms 68548 KB
testcase_17 AC 81 ms 68004 KB
testcase_18 AC 96 ms 68572 KB
testcase_19 AC 88 ms 68568 KB
testcase_2 AC 68 ms 68348 KB
testcase_20 AC 101 ms 68240 KB
testcase_3 AC 64 ms 68124 KB
testcase_4 AC 64 ms 67908 KB
testcase_5 AC 58 ms 64816 KB
testcase_6 AC 54 ms 64516 KB
testcase_7 AC 81 ms 68140 KB
testcase_8 AC 112 ms 68688 KB
testcase_9 AC 114 ms 68244 KB