Submission #19551923


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_list):
    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 553 Byte
Status AC
Exec Time 146 ms
Memory 27828 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 120 ms 26940 KB
sample_02 AC 119 ms 26972 KB
sample_03 AC 114 ms 27032 KB
testcase_0 AC 114 ms 27172 KB
testcase_1 AC 115 ms 26616 KB
testcase_10 AC 123 ms 27188 KB
testcase_11 AC 120 ms 26928 KB
testcase_12 AC 115 ms 27228 KB
testcase_13 AC 132 ms 27808 KB
testcase_14 AC 115 ms 27040 KB
testcase_15 AC 117 ms 26644 KB
testcase_16 AC 119 ms 27160 KB
testcase_17 AC 128 ms 27796 KB
testcase_18 AC 132 ms 27472 KB
testcase_19 AC 131 ms 27692 KB
testcase_2 AC 117 ms 26964 KB
testcase_20 AC 135 ms 27480 KB
testcase_3 AC 114 ms 27236 KB
testcase_4 AC 113 ms 27032 KB
testcase_5 AC 115 ms 26912 KB
testcase_6 AC 111 ms 27188 KB
testcase_7 AC 146 ms 27828 KB
testcase_8 AC 145 ms 27656 KB
testcase_9 AC 141 ms 27572 KB