#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 = 0; 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 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
3 ms |
212 KB |
Output is correct |
4 |
Correct |
18 ms |
316 KB |
Output is correct |
5 |
Correct |
357 ms |
304 KB |
Output is correct |
6 |
Correct |
2436 ms |
312 KB |
Output is correct |
7 |
Correct |
188 ms |
300 KB |
Output is correct |
8 |
Execution timed out |
7027 ms |
216 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
7031 ms |
212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
7031 ms |
212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
7031 ms |
212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
3 ms |
212 KB |
Output is correct |
4 |
Correct |
18 ms |
316 KB |
Output is correct |
5 |
Correct |
357 ms |
304 KB |
Output is correct |
6 |
Correct |
2436 ms |
312 KB |
Output is correct |
7 |
Correct |
188 ms |
300 KB |
Output is correct |
8 |
Execution timed out |
7027 ms |
216 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
3 ms |
212 KB |
Output is correct |
4 |
Correct |
18 ms |
316 KB |
Output is correct |
5 |
Correct |
357 ms |
304 KB |
Output is correct |
6 |
Correct |
2436 ms |
312 KB |
Output is correct |
7 |
Correct |
188 ms |
300 KB |
Output is correct |
8 |
Execution timed out |
7027 ms |
216 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |