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;
typedef vector<int> vi;
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
int N, Q;
vi A;
vi B;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin >> N >> Q;
A.resize(N);
for (int i = 0; i < N; ++i)
cin >> A[i];
while (Q--)
{
int lx, rx;
cin >> lx >> rx;
--lx;
B = vi(A.begin() + lx, A.begin() + rx);
sort(all(B));
ll ans = 0;
for (int l = 0; l < sz(B); ++l)
for (int r = l + 1; r <= sz(B); ++r)
{
int tmp = -1;
for (int i = l; i < r; ++i)
if (B[i] != tmp)
++ans, tmp = B[i];
}
cout << ans << "\n";
}
return 0;
}
# | 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... |