#include #include #include int contena[1000001]; int main(){ //std::vector contena; int n, k; std::cin >> n >> k; int m = 0; int d = 0; for (int i = 0; i < n; ++i){ int w; std::cin >> w; m = std::max(m, w); if (w > 0){ int cnt = 0; for (int j = m; j >= w; --j){ if (contena[j] == 0)continue; cnt += contena[j]; } if (cnt < k){ contena[w]++; //std::cout << w << "gain" << std::endl; } } else{ if (contena[-w] > 0){ contena[-w]--; //std::cout << -w << "minus" << std::endl; } //contena.erase(std::remove(contena.begin(), contena.end(), -w),contena.end()); } } int ans = 0; for (int i = 1; i <= m; ++i){ if (contena[i] == 0){ continue; //std::cout << i<<" "<