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;
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;
sort(a + 1, a + n + 1);
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();
}
}
cout << sum << '\n';
}
}
# | 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... |