Submission #19526326


Source Code Expand

Copy
n,k = map(int, input().split())
lst = list(map(int, input().split()))

mod = 10**9+7

s = 0
t = 0

for i in range(n):
    for j in range(i):
        if lst[j]<lst[i]:
            s += 1
            s %= mod
    for j in range(i,n):
        if lst[j]<lst[i]:
            s += 1
            s %= mod
            t += 1
            t %= mod

print((s*k*(k-1)//2%mod + t*k%mod)%mod)

Submission Info

Submission Time
Task B - Kleene Inversion
User shotam
Language Python (3.8.2)
Score 300
Code Size 402 Byte
Status AC
Exec Time 822 ms
Memory 9260 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 26 ms 9016 KB
sample_02 AC 26 ms 9164 KB
sample_03 AC 19 ms 9164 KB
testcase_0 AC 23 ms 8888 KB
testcase_1 AC 22 ms 9064 KB
testcase_10 AC 112 ms 8900 KB
testcase_11 AC 70 ms 9028 KB
testcase_12 AC 19 ms 8884 KB
testcase_13 AC 331 ms 8912 KB
testcase_14 AC 40 ms 9028 KB
testcase_15 AC 34 ms 8896 KB
testcase_16 AC 76 ms 8896 KB
testcase_17 AC 222 ms 9140 KB
testcase_18 AC 373 ms 9260 KB
testcase_19 AC 318 ms 8972 KB
testcase_2 AC 25 ms 9160 KB
testcase_20 AC 518 ms 9104 KB
testcase_3 AC 18 ms 9088 KB
testcase_4 AC 19 ms 9012 KB
testcase_5 AC 19 ms 9164 KB
testcase_6 AC 19 ms 8892 KB
testcase_7 AC 449 ms 9060 KB
testcase_8 AC 822 ms 9056 KB
testcase_9 AC 805 ms 9056 KB