#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
mt19937 rng(123);
#define ld long double
#define ull unsigned long long
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(a) a.begin(), a.end()
#define ff first
#define ss second
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define setp(x) setprecision(x)
ll mod=1e9+7;
int inf=1e9;
const int LOGN = 20;
const int MXX=3e5;
const long double PI = 3.1415926535897932384626433832795;
int calc(vector<int> v){
int ans = 0;
int n = v.size();
for(int i = 0; i < n; i ++){
set<int> st;
for(int j = i; j < n; j ++){
st.insert(v[j]); ans += st.size();
}
}
return ans;
}
void solve(){
int n, q; cin >> n >> q;
vector<int> v(n);
for(auto &u:v) cin >> u;
sort(all(v));
int ans = 1e9;
do{
ans = min(ans, calc(v));
}while(next_permutation(all(v)));
cout << ans << endl;
}
int main(){
int testcases = 1;
// cin >> testcases;
while(testcases --){
solve(); if(testcases) cout << '\n';
cout << endl;
}
}
# |
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 |
4 ms |
304 KB |
Output is correct |
4 |
Correct |
67 ms |
284 KB |
Output is correct |
5 |
Correct |
470 ms |
284 KB |
Output is correct |
6 |
Correct |
3386 ms |
284 KB |
Output is correct |
7 |
Execution timed out |
7032 ms |
212 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
7024 ms |
212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
7024 ms |
212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
7024 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 |
4 ms |
304 KB |
Output is correct |
4 |
Correct |
67 ms |
284 KB |
Output is correct |
5 |
Correct |
470 ms |
284 KB |
Output is correct |
6 |
Correct |
3386 ms |
284 KB |
Output is correct |
7 |
Execution timed out |
7032 ms |
212 KB |
Time limit exceeded |
8 |
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 |
4 ms |
304 KB |
Output is correct |
4 |
Correct |
67 ms |
284 KB |
Output is correct |
5 |
Correct |
470 ms |
284 KB |
Output is correct |
6 |
Correct |
3386 ms |
284 KB |
Output is correct |
7 |
Execution timed out |
7032 ms |
212 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |