Submission #881880

# Submission time Handle Problem Language Result Execution time Memory
881880 2023-12-02T07:07:10 Z TAhmed33 Diversity (CEOI21_diversity) C++
0 / 100
7000 ms 600 KB
#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 time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 12 ms 516 KB Output is correct
5 Correct 278 ms 348 KB Output is correct
6 Correct 2636 ms 420 KB Output is correct
7 Correct 137 ms 416 KB Output is correct
8 Execution timed out 7004 ms 600 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 7053 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 7053 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 7053 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 12 ms 516 KB Output is correct
5 Correct 278 ms 348 KB Output is correct
6 Correct 2636 ms 420 KB Output is correct
7 Correct 137 ms 416 KB Output is correct
8 Execution timed out 7004 ms 600 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 12 ms 516 KB Output is correct
5 Correct 278 ms 348 KB Output is correct
6 Correct 2636 ms 420 KB Output is correct
7 Correct 137 ms 416 KB Output is correct
8 Execution timed out 7004 ms 600 KB Time limit exceeded
9 Halted 0 ms 0 KB -