Submission #19551894


Source Code Expand

Copy
# -*- coding: utf-8 -*-
import sys
import numpy as np

readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, K = map(int, readline().decode("utf-8").rsplit(" "))
a = np.fromstring(sys.stdin.readline(), dtype=np.int64, sep=" ")
a_list = a.tolist()
first = 0
after = 0
for i, a_i in enumerate(a):
    after += np.sum(a_i > a)
    first += np.sum(a_i > a[i:])

first, after = int(first), int(after)
mod = 10 ** 9 + 7

anser = (first * K % mod) + ((after * (K * (K - 1)) // 2) % mod)

print(anser % mod)

Submission Info

Submission Time
Task B - Kleene Inversion
User sayonobi
Language Python (3.8.2)
Score 300
Code Size 548 Byte
Status AC
Exec Time 139 ms
Memory 27888 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 115 ms 27036 KB
sample_02 AC 107 ms 27040 KB
sample_03 AC 105 ms 27020 KB
testcase_0 AC 106 ms 26940 KB
testcase_1 AC 105 ms 27128 KB
testcase_10 AC 112 ms 26968 KB
testcase_11 AC 114 ms 27236 KB
testcase_12 AC 108 ms 27132 KB
testcase_13 AC 125 ms 27316 KB
testcase_14 AC 112 ms 27068 KB
testcase_15 AC 110 ms 27148 KB
testcase_16 AC 119 ms 27204 KB
testcase_17 AC 122 ms 27500 KB
testcase_18 AC 124 ms 27640 KB
testcase_19 AC 127 ms 27684 KB
testcase_2 AC 103 ms 27248 KB
testcase_20 AC 129 ms 27708 KB
testcase_3 AC 110 ms 27080 KB
testcase_4 AC 108 ms 27296 KB
testcase_5 AC 107 ms 27072 KB
testcase_6 AC 108 ms 27240 KB
testcase_7 AC 139 ms 27888 KB
testcase_8 AC 135 ms 27640 KB
testcase_9 AC 132 ms 27756 KB