Submission #7571070


Source Code Expand

Copy
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include<vector>
#include<utility>
#include<fstream>
#include<queue>
#include <iomanip>
#include<numeric>
#include<set>
using namespace std;
typedef long long ll;
#define rep(i,k) for(i=0;i<k;i++)
#define P pair<ll,ll>
ll mod = 1000000007;
P p[200005];

ll i, b, c, k, j, n, m, z = 0, mi = 10;
ll a[2005] = {};
vector<ll> v[30];
string s;
char ca[10000];
priority_queue<ll> q;
int main() {
	cin >> n>>k;
	rep(i, n)cin>>a[i];

	rep(i, n)rep(j, n) {
		if (a[i] > a[j]) {
			if (i < j)b++;
			if (i > j)c++;
		}
	}
	m=b+c;
	z = z+(b * k) % mod;
	ll bb = 0;
	bb = ((k - 1) * k / 2)%mod;
	z = (z+m* bb) % mod;
	cout << z;

	return 0;
}

Submission Info

Submission Time
Task B - Kleene Inversion
User janki
Language C++14 (GCC 5.4.1)
Score 300
Code Size 787 Byte
Status
Exec Time 12 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 4 ms 256 KB
testcase_14 1 ms 256 KB
testcase_15 1 ms 256 KB
testcase_16 2 ms 256 KB
testcase_17 4 ms 256 KB
testcase_18 6 ms 256 KB
testcase_19 5 ms 256 KB
testcase_2 1 ms 256 KB
testcase_20 8 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 4 ms 256 KB
testcase_8 12 ms 256 KB
testcase_9 12 ms 256 KB