Submission #19537705


Source Code Expand

Copy
n, k = map(int, input().split())
A = tuple(map(int, input().split()))
mod = 10**9+7
tenl = []
tenr = []
for j in range(n):
    cnt = 0
    for i in range(j):
        if A[j] < A[i]:
            cnt += 1
    tenl.append(cnt)
    cnt = 0
    for i in range(j+1, n):
        if A[j] < A[i]:
            cnt += 1
    tenr.append(cnt)
ans = 0
for i in range(n):
    ans += (k*(k+1)//2 * tenl[i])%mod + (k*(k-1)//2 * tenr[i])%mod
    ans %= mod
print(ans)

Submission Info

Submission Time
Task B - Kleene Inversion
User omr14t
Language PyPy3 (7.3.0)
Score 300
Code Size 469 Byte
Status AC
Exec Time 98 ms
Memory 73916 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 61448 KB
sample_02 AC 50 ms 61704 KB
sample_03 AC 49 ms 61580 KB
testcase_0 AC 53 ms 63616 KB
testcase_1 AC 52 ms 63328 KB
testcase_10 AC 62 ms 68496 KB
testcase_11 AC 58 ms 68212 KB
testcase_12 AC 50 ms 61760 KB
testcase_13 AC 77 ms 73724 KB
testcase_14 AC 58 ms 67804 KB
testcase_15 AC 55 ms 67504 KB
testcase_16 AC 61 ms 68636 KB
testcase_17 AC 66 ms 69356 KB
testcase_18 AC 74 ms 71748 KB
testcase_19 AC 75 ms 72036 KB
testcase_2 AC 53 ms 63984 KB
testcase_20 AC 86 ms 73824 KB
testcase_3 AC 48 ms 63724 KB
testcase_4 AC 50 ms 63820 KB
testcase_5 AC 51 ms 61720 KB
testcase_6 AC 49 ms 61740 KB
testcase_7 AC 71 ms 69544 KB
testcase_8 AC 98 ms 73852 KB
testcase_9 AC 98 ms 73916 KB