Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool ok(int m, int mx) {
- // map<int, int> hash;
- vi hash(N + 1, 0);
- f(i, 0, m) hash[v[i]]++;
- set<int> st;
- f(i, 0, n + 5)
- {
- if(hash[i] == 0)
- {
- st.insert(i);
- }
- }
- if(*st.begin() == mx) return true;
- f(i, m, n)
- {
- hash[v[i]]++;
- if(st.find(v[i]) != st.end()) st.erase(v[i]);
- hash[v[i - m]]--;
- if(hash[v[i - m]] == 0)
- {
- st.insert(v[i - m]);
- }
- if(*st.begin() == mx) return true;
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment