fork(1) download
  1. #include <ext/pb_ds/assoc_container.hpp>
  2. #include <ext/pb_ds/tree_policy.hpp>
  3. #include <bits/stdc++.h>
  4. #define ll long long
  5. using namespace __gnu_pbds;
  6. using namespace std;
  7.  
  8. typedef
  9. tree<
  10. ll,
  11. null_type,
  12. less<ll>,
  13. rb_tree_tag,
  14. tree_order_statistics_node_update>
  15. ordered_set;
  16.  
  17. main()
  18. {
  19. ios::sync_with_stdio(0);
  20. cin.tie(0);
  21.  
  22. ordered_set t;
  23. ll q,k,c,x,y,a;
  24. cin>>q>>k;
  25. a=q;
  26. while(a--){
  27. cin>>c;
  28. if(c==1){
  29. cin>>x>>y;
  30. t.insert((x*x+y*y));
  31. }
  32. else if(c==2){
  33. cout<<*t.find_by_order(k-1)<<"\n";
  34. }
  35. }
  36. }
  37.  
Success #stdin #stdout 0s 15240KB
stdin
9 3
1 10 10
1 9 9
1 -8 -8
2
1 7 7
2
1 6 6 
1 5 5
2
stdout
200
162
98