fork(8) download
  1. #include <bits/stdc++.h>
  2. #include <ext/pb_ds/assoc_container.hpp>
  3. #include <ext/pb_ds/tree_policy.hpp>
  4.  
  5. using namespace std;
  6. using namespace __gnu_pbds;
  7.  
  8. typedef tree<
  9. int,
  10. null_type,
  11. less<int>,
  12. rb_tree_tag,
  13. tree_order_statistics_node_update> ordered_set;
  14.  
  15. main()
  16. {
  17. ios::sync_with_stdio(0);
  18. cin.tie(0);
  19. int n;
  20. cin >> n;
  21. ordered_set me;
  22. while(n--)
  23. {
  24. char t;
  25. int x;
  26. cin >> t >> x;
  27. if(t == 'K')
  28. if(x > me.size())
  29. cout << "invalid\n";
  30. else
  31. cout << *me.find_by_order(x - 1) << "\n";
  32. if(t == 'C')
  33. cout << me.order_of_key(x) << "\n";
  34. if(t == 'I')
  35. me.insert(x);
  36. if(t == 'D')
  37. me.erase(x);
  38. }
  39. }
  40.  
  41.  
Time limit exceeded #stdin #stdout 5s 3240KB
stdin
Standard input is empty
stdout
Standard output is empty