#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define sz(x) (int)x.size()
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n, q;
cin >> n >> q;
vector<int> a(n + 1);
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
sort(a.begin() + 1, a.end());
int _, __;
cin >> _ >> __;
ll ans = -1;
do {
ll cur = 0;
bool f = false;
for (int l = 1; l <= n; l++) {
set<int> s;
for (int r = l; r <= n; r++) {
s.insert(a[r]);
cur += sz(s);
if (ans != -1 && cur >= ans) {
f = true;
break;
}
}
if (f)
break;
}
if (ans == -1)
ans = cur;
ans = min(ans, cur);
} while (next_permutation(a.begin() + 1, a.end()));
cout << ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
3 ms |
204 KB |
Output is correct |
4 |
Correct |
44 ms |
204 KB |
Output is correct |
5 |
Correct |
317 ms |
288 KB |
Output is correct |
6 |
Correct |
2286 ms |
292 KB |
Output is correct |
7 |
Execution timed out |
7062 ms |
204 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
7051 ms |
204 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
7051 ms |
204 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
7051 ms |
204 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
3 ms |
204 KB |
Output is correct |
4 |
Correct |
44 ms |
204 KB |
Output is correct |
5 |
Correct |
317 ms |
288 KB |
Output is correct |
6 |
Correct |
2286 ms |
292 KB |
Output is correct |
7 |
Execution timed out |
7062 ms |
204 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
3 ms |
204 KB |
Output is correct |
4 |
Correct |
44 ms |
204 KB |
Output is correct |
5 |
Correct |
317 ms |
288 KB |
Output is correct |
6 |
Correct |
2286 ms |
292 KB |
Output is correct |
7 |
Execution timed out |
7062 ms |
204 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |