fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #include <ext/pb_ds/assoc_container.hpp>
  4. #include <ext/pb_ds/tree_policy.hpp>
  5. using namespace __gnu_pbds;
  6.  
  7. #define ordered_set tree<int, null_type,greater<int>, rb_tree_tag,tree_order_statistics_node_update>
  8.  
  9. const int MAXN = (1e6) + 7;
  10. vector< int > adj[MAXN];
  11. set < int > st;
  12. int deg[MAXN];
  13. int vis[MAXN];
  14. void ALI_72(){
  15. int n,m;
  16. cin>>n>>m;
  17. ordered_set o;
  18. int val;
  19. for(int i=1;i<=n;i++){
  20. cin >> val;
  21. o.insert(val);
  22. if(i>=m){
  23. cout<<*(o.find_by_order(m-1))<<endl;
  24. }
  25.  
  26. }
  27. }
  28.  
  29. signed main()
  30. {
  31. ios_base :: sync_with_stdio(0);
  32. cin.tie(0), cout.tie(0);
  33. int t = 1;
  34. //cin >> t;
  35. while(t--){
  36. ALI_72();
  37. }
  38.  
  39. return 0;
  40. }
  41.  
Success #stdin #stdout 0.01s 27224KB
stdin
Standard input is empty
stdout
Standard output is empty