Submission #7562398


Source Code Expand

Copy
#include <iostream>
#include <vector>

int main()
{
    const int mod = 1000000007;
    long long n, k;
    std::cin >> n >> k;

    std::vector<int> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }

    long long p = 0;
    for (int i = 0; i < n - 1; i++) {
        for (int j = i + 1; j < n; j++) {
            if (a[i] > a[j]) {
                p++;
                p %= mod;
            }
        }
    }

    long long q = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (a[i] > a[j]) {
                q++;
                q %= mod;
            }
        }
    }

    p *= k;
    p %= mod;

    q *= ((k * (k - 1) / 2) % mod);

    p += q;
    p %= mod;
    std::cout << p << std::endl;
}

Submission Info

Submission Time
Task B - Kleene Inversion
User toku_san
Language C++14 (GCC 5.4.1)
Score 300
Code Size 803 Byte
Status
Exec Time 22 ms
Memory 256 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 1 ms 256 KB
sample_02 1 ms 256 KB
sample_03 1 ms 256 KB
testcase_0 1 ms 256 KB
testcase_1 1 ms 256 KB
testcase_10 2 ms 256 KB
testcase_11 2 ms 256 KB
testcase_12 1 ms 256 KB
testcase_13 8 ms 256 KB
testcase_14 2 ms 256 KB
testcase_15 1 ms 256 KB
testcase_16 2 ms 256 KB
testcase_17 6 ms 256 KB
testcase_18 10 ms 256 KB
testcase_19 9 ms 256 KB
testcase_2 1 ms 256 KB
testcase_20 14 ms 256 KB
testcase_3 1 ms 256 KB
testcase_4 1 ms 256 KB
testcase_5 1 ms 256 KB
testcase_6 1 ms 256 KB
testcase_7 5 ms 256 KB
testcase_8 22 ms 256 KB
testcase_9 22 ms 256 KB