# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
964836 | MinaRagy06 | Diversity (CEOI21_diversity) | C++17 | 1 ms | 348 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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());
int 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();
}
}
cout << ans << '\n';
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |