Submission #952974

# Submission time Handle Problem Language Result Execution time Memory
952974 2024-03-25T08:18:39 Z Sacharlemagne Diversity (CEOI21_diversity) C++17
4 / 100
7000 ms 604 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
int main() {
	//ios_base::sync_with_stdio(false); cin.tie(nullptr);
	int n,q; cin >> n >> q;
	vector<int> vv(n); for (int i = 0; i<n; ++i) cin >> vv[i];
	while (q--) {
		long long fin = 4e18;
		int L, R;
		cin >> L >> R;
		--L; --R;
		vector<int> v(R-L+1); for (int i = 0; i<R-L+1; ++i) v[i] = vv[i+L];
		do {
			ll ans = 0;
			map<ll,ll> last;
			for (ll i = 0; i<v.size(); ++i) {
				int bef = last[v[i]];
				ans += (i-bef+1)*(v.size()-i);
				last[v[i]] = i+1;
			}
			fin = min(fin, ans);

		} while (next_permutation(v.begin(), v.end()));
		cout << fin << '\n';
	}
	return 0;
}
/*
 *
 */

Compilation message

diversity.cpp: In function 'int main()':
diversity.cpp:18:20: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |    for (ll i = 0; i<v.size(); ++i) {
      |                   ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 4 ms 604 KB Output is correct
5 Correct 48 ms 348 KB Output is correct
6 Correct 357 ms 408 KB Output is correct
7 Correct 29 ms 348 KB Output is correct
8 Correct 3320 ms 348 KB Output is correct
9 Correct 1359 ms 416 KB Output is correct
10 Correct 4423 ms 592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 7015 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 7015 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 7015 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 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 4 ms 604 KB Output is correct
5 Correct 48 ms 348 KB Output is correct
6 Correct 357 ms 408 KB Output is correct
7 Correct 29 ms 348 KB Output is correct
8 Correct 3320 ms 348 KB Output is correct
9 Correct 1359 ms 416 KB Output is correct
10 Correct 4423 ms 592 KB Output is correct
11 Execution timed out 7015 ms 348 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 4 ms 604 KB Output is correct
5 Correct 48 ms 348 KB Output is correct
6 Correct 357 ms 408 KB Output is correct
7 Correct 29 ms 348 KB Output is correct
8 Correct 3320 ms 348 KB Output is correct
9 Correct 1359 ms 416 KB Output is correct
10 Correct 4423 ms 592 KB Output is correct
11 Execution timed out 7015 ms 348 KB Time limit exceeded
12 Halted 0 ms 0 KB -