This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int nmax = 3e5;
const int oo = INT_MAX;
int n,q;
int v[nmax + 5];
bool sel[nmax + 5];
int main()
{
#ifdef home
freopen("nr.in","r",stdin);
freopen("nr.out","w",stdout);
#endif // home
cin>>n>>q;
for(int i=1;i<=n;i++)
{
cin>>v[i];
}
sort(v+1,v+n+1);
int x,y;
cin>>x>>y;
int Min = oo;
do
{
int rez = 0;
for(int i=1;i<=n;i++)
{
int nr = 0;
for(int j=i;j<=n;j++)
{
if(!sel[v[j]])
{
++nr;
}
sel[v[j]] = true;
rez += nr;
}
for(int j=i;j<=n;j++)
{
sel[v[j]] = false;
}
}
Min = min(Min, rez);
}
while(next_permutation(v+1,v+n+1));
cout<<Min<<'\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... |