Submission #964838

# Submission time Handle Problem Language Result Execution time Memory
964838 2024-04-17T16:02:38 Z MinaRagy06 Diversity (CEOI21_diversity) C++17
0 / 100
7000 ms 436 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	int n, q;
	cin >> n >> q;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	while (q--) {
		int l, r;
		cin >> l >> r;
		l--, r--;
		vector<int> v;
		for (int i = l; i <= r; i++) {
			v.push_back(a[i]);
		}
		sort(v.begin(), v.end());
		ll mn = 1e18;
		do {
			ll ans = 0;
			for (int i = 0; i < v.size(); i++) {
				set<int> s;
				for (int j = i; j < v.size(); j++) {
					s.insert(v[j]);
					ans += s.size();
				}
			}
			mn = min(mn, ans);
		} while (next_permutation(v.begin(), v.end()));
		cout << mn << '\n';
	}
	return 0;
}

Compilation message

diversity.cpp: In function 'int main()':
diversity.cpp:25:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |    for (int i = 0; i < v.size(); i++) {
      |                    ~~^~~~~~~~~~
diversity.cpp:27:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for (int j = i; j < v.size(); j++) {
      |                     ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 59 ms 432 KB Output is correct
5 Correct 421 ms 432 KB Output is correct
6 Correct 2953 ms 436 KB Output is correct
7 Execution timed out 7039 ms 344 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 7048 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 7048 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 7048 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 59 ms 432 KB Output is correct
5 Correct 421 ms 432 KB Output is correct
6 Correct 2953 ms 436 KB Output is correct
7 Execution timed out 7039 ms 344 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 59 ms 432 KB Output is correct
5 Correct 421 ms 432 KB Output is correct
6 Correct 2953 ms 436 KB Output is correct
7 Execution timed out 7039 ms 344 KB Time limit exceeded
8 Halted 0 ms 0 KB -