Submission #859576

#TimeUsernameProblemLanguageResultExecution timeMemory
859576Tenis0206Diversity (CEOI21_diversity)C++11
4 / 100
7063 ms432 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...