Submission #881880

#TimeUsernameProblemLanguageResultExecution timeMemory
881880TAhmed33Diversity (CEOI21_diversity)C++98
0 / 100
7053 ms600 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MAXN = 3e5 + 25; int n, a[MAXN], q; int main () { cin >> n >> q; for (int i = 1; i <= n; i++) cin >> a[i]; while (q--) { int l, r; cin >> l >> r; ll mn = 1e18; do { ll sum = 0; for (int i = 1; i <= n; i++) { set <int> dd; for (int j = i; j <= n; j++) { dd.insert(a[j]); sum += dd.size(); } } mn = min(mn, sum); } while (next_permutation(a + 1, a + n + 1)); cout << mn << '\n'; } }
#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...