#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll MAXN = 3e5 + 5;
const ll MAXQ = 5e4 + 5;
const ll MAX = 1e18;
ll n, q, ans = MAX;
ll arr[MAXN];
bool occur[MAXN];
ll calc() {
ll out = 0;
for (int i = 1; i <= n; ++i) {
ll cnt = 0;
for (int j = i; j <= n; ++j) {
if (!occur[arr[j]]) {
cnt++;
occur[arr[j]] = true;
}
out += cnt;
}
for (int j = i; j <= n; ++j) {
occur[arr[j]] = false;
}
}
return out;
}
int main() {
cin >> n >> q;
for (int i = 1; i <= n; ++i) {
cin >> arr[i];
}
ll _tmp;
cin >> _tmp >> _tmp;
sort(arr+1, arr+1+n);
do {
ans = min(ans, calc());
} while (next_permutation(arr+1, arr+1+n));
cout << ans << "\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |