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 int long long
map<int, int> val;
bool cmp(int a, int b){
return val[a] < val[b];
}
signed main()
{
int n, q; cin >> n >> q;
vector<int> a(n);
for (int i = 0; i < n; i++){
cin >> a[i];
val[a[i]]++;
}
sort(a.begin(), a.end(), cmp);
int ans = 0;
while(q--){
int l, r; cin >> l >> r;
l--; r--;
for (int i = 0; i < n; i++){
set<int> v;
for (int j = i; j < n; j++){
v.insert(a[j]);
ans += v.size();
}
}
}
cout << ans << endl;
}
# | 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... |