#include <iostream>
#include <vector>
#include <unordered_map>
#include <set>
using namespace std;
int main() {
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 |
344 KB |
Output isn't correct |
2 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |
3 |
Incorrect |
3 ms |
348 KB |
Output isn't correct |
4 |
Incorrect |
45 ms |
344 KB |
Output isn't correct |
5 |
Execution timed out |
5087 ms |
1764 KB |
Time limit exceeded |
6 |
Execution timed out |
5036 ms |
2024 KB |
Time limit exceeded |
7 |
Execution timed out |
5012 ms |
2916 KB |
Time limit exceeded |
8 |
Execution timed out |
5048 ms |
3400 KB |
Time limit exceeded |
9 |
Execution timed out |
5061 ms |
3824 KB |
Time limit exceeded |
10 |
Execution timed out |
5045 ms |
4716 KB |
Time limit exceeded |