Submission #861009

#TimeUsernameProblemLanguageResultExecution timeMemory
861009ratiPoklon (COCI17_poklon)C++14
0 / 140
5087 ms4716 KiB
#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; }
#Verdict Execution timeMemoryGrader output
Fetching results...