Submission #19526335


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 PyPy3 (7.3.0)
Score 300
Code Size 402 Byte
Status AC
Exec Time 100 ms
Memory 71224 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 64 ms 61584 KB
sample_02 AC 53 ms 61196 KB
sample_03 AC 55 ms 61568 KB
testcase_0 AC 56 ms 63844 KB
testcase_1 AC 60 ms 64016 KB
testcase_10 AC 69 ms 68340 KB
testcase_11 AC 64 ms 68220 KB
testcase_12 AC 53 ms 61672 KB
testcase_13 AC 79 ms 70080 KB
testcase_14 AC 65 ms 68240 KB
testcase_15 AC 62 ms 67156 KB
testcase_16 AC 66 ms 68004 KB
testcase_17 AC 74 ms 68332 KB
testcase_18 AC 79 ms 69672 KB
testcase_19 AC 78 ms 70360 KB
testcase_2 AC 59 ms 64352 KB
testcase_20 AC 86 ms 70968 KB
testcase_3 AC 59 ms 63888 KB
testcase_4 AC 60 ms 63948 KB
testcase_5 AC 54 ms 61636 KB
testcase_6 AC 54 ms 61372 KB
testcase_7 AC 70 ms 67456 KB
testcase_8 AC 100 ms 71224 KB
testcase_9 AC 95 ms 70000 KB