Submission #7571580


Source Code Expand

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

count = 0

for j in range(0,n):
  for i in range(0,n):
    if a[j]>a[i]:
#      print(j,i)
      if j >= i:
        count += (k-1)*k//2
      else:
        count += k*(k+1)//2
#      print(count)
print(count%(10**9+7))

Submission Info

Submission Time
Task B - Kleene Inversion
User kuni0815
Language Python3 (3.4.3)
Score 300
Code Size 300 Byte
Status
Exec Time 1130 ms
Memory 3316 KB

Test Cases

Set Name Score / Max Score Test Cases
All 300 / 300 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 0 / 0 sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
sample_01 24 ms 3316 KB
sample_02 17 ms 3060 KB
sample_03 17 ms 2940 KB
testcase_0 18 ms 3064 KB
testcase_1 18 ms 2940 KB
testcase_10 136 ms 2940 KB
testcase_11 78 ms 3060 KB
testcase_12 17 ms 2940 KB
testcase_13 430 ms 3060 KB
testcase_14 41 ms 3060 KB
testcase_15 31 ms 2940 KB
testcase_16 76 ms 3060 KB
testcase_17 308 ms 3060 KB
testcase_18 548 ms 3060 KB
testcase_19 447 ms 3060 KB
testcase_2 18 ms 3060 KB
testcase_20 735 ms 3188 KB
testcase_3 18 ms 3060 KB
testcase_4 18 ms 2940 KB
testcase_5 17 ms 2940 KB
testcase_6 17 ms 2940 KB
testcase_7 516 ms 3060 KB
testcase_8 1130 ms 3188 KB
testcase_9 1105 ms 3188 KB