#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const long long N = 3e5 + 5;
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n, q; cin >> n >> q;
vector <int> a(n);
for (int i = 1; i <= n; i++) cin >> a[i];
int l, r; cin >> l >> r;
ll ans = 0;
for (int i = 0; i < n; i++) {
set<int> s;
for (int j = i; j < n; j++) {
s.insert(a[j]);
ans += s.size();
}
} while (next_permutation(a.begin(), a.end())) {
ll res = 0;
for (int i = 0; i < n; i++) {
set<int> s;
for (int j = i; j < n; j++) {
s.insert(a[j]);
res += s.size();
}
} ans = min(ans, res);
} cout << ans << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
7094 ms |
212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
7094 ms |
212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
7094 ms |
212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |