#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)
{
set<int> tmp(B.begin() + l, B.begin() + r);
ans += sz(tmp);
}
cout << ans << "\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |