#include <iostream>
#include <vector>
#include <unordered_map>
#include <set>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int N, Q;
cin >> N >> Q;
vector<int> array(N);
for (int i = 0; i < N; i++) {
cin >> array[i];
}
unordered_map<int, int> count;
for (int num : array) {
count[num]++;
}
for (int q = 0; q < Q; q++) {
int L, R;
cin >> L >> R;
set<int> unique_twice;
for (int i = L - 1; i < R; i++) {
if (count[array[i]] == 2) {
unique_twice.insert(array[i]);
}
}
cout << unique_twice.size() << endl;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Incorrect |
3 ms |
348 KB |
Output isn't correct |
4 |
Incorrect |
43 ms |
480 KB |
Output isn't correct |
5 |
Execution timed out |
5039 ms |
1392 KB |
Time limit exceeded |
6 |
Execution timed out |
5057 ms |
1356 KB |
Time limit exceeded |
7 |
Execution timed out |
5021 ms |
1616 KB |
Time limit exceeded |
8 |
Execution timed out |
5056 ms |
1664 KB |
Time limit exceeded |
9 |
Execution timed out |
5065 ms |
2048 KB |
Time limit exceeded |
10 |
Execution timed out |
5050 ms |
2436 KB |
Time limit exceeded |